Skip to content

Commit

Permalink
Merge pull request #11 from Moros1138/develop
Browse files Browse the repository at this point in the history
v1.7
  • Loading branch information
Moros1138 authored Sep 4, 2024
2 parents b52b726 + 381d6af commit 04b66f3
Show file tree
Hide file tree
Showing 8 changed files with 1,412 additions and 11 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/emscripten-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Emscripten Build

on:
push:
branches:
- develop
pull_request:
branches:
- develop
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout source code
uses: actions/checkout@v3
with:
submodules: 'recursive'

- name: Set up Python (required for Emscripten)
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install Emscripten SDK
run: |
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
shell: bash

- name: Build with Emscripten
run: |
source emsdk/emsdk_env.sh
cd demo
make emscripten
shell: bash


70 changes: 70 additions & 0 deletions .github/workflows/emscripten-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Emscripten Deploy

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout source code
uses: actions/checkout@v3
with:
submodules: 'recursive'

- name: Set up Python (required for Emscripten)
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install Emscripten SDK
run: |
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
shell: bash

- name: Build with Emscripten
run: |
source emsdk/emsdk_env.sh
cd demo
make emscripten
shell: bash

- name: Deploy Main Demo
uses: appleboy/[email protected]
with:
host: ${{ secrets.REMOTE_SERVER_ADDR }}
username: ${{ secrets.REMOTE_SERVER_USER }}
key: ${{ secrets.REMOTE_SERVER_SSH_KEY }}
port: ${{ secrets.REMOTE_SERVER_PORT }}
source: "demo/demo.html,demo/demo.js,demo/demo.wasm,demo/demo.data"
target: ${{ secrets.REMOTE_SERVER_DIRECTORY }}
strip_components: 1

- name: Deploy Waveform Demo
uses: appleboy/[email protected]
with:
host: ${{ secrets.REMOTE_SERVER_ADDR }}
username: ${{ secrets.REMOTE_SERVER_USER }}
key: ${{ secrets.REMOTE_SERVER_SSH_KEY }}
port: ${{ secrets.REMOTE_SERVER_PORT }}
source: "demo/demo_waveform.html,demo/demo_waveform.js,demo/demo_waveform.wasm,demo/demo_waveform.data"
target: ${{ secrets.REMOTE_SERVER_DIRECTORY }}
strip_components: 1

- name: Deploy Synthesis Demo
uses: appleboy/[email protected]
with:
host: ${{ secrets.REMOTE_SERVER_ADDR }}
username: ${{ secrets.REMOTE_SERVER_USER }}
key: ${{ secrets.REMOTE_SERVER_SSH_KEY }}
port: ${{ secrets.REMOTE_SERVER_PORT }}
source: "demo/demo_synthesis.html,demo/demo_synthesis.js,demo/demo_synthesis.wasm,demo/demo_synthesis.data"
target: ${{ secrets.REMOTE_SERVER_DIRECTORY }}
strip_components: 1
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ files. Because it's built on top of [miniaudio](https://miniaud.io), it requires
to no additional build configurations in order to be built
for cross-platform.

See the emscripten version [running on the web here](https://www.moros1138.com/demos/olcPGEX_MiniAudio/).
See the emscripten versions of the demos here:
* [Main Demo](https://www.moros1138.com/demos/olcPGEX_MiniAudio/).
* [Waveform Demo](https://www.moros1138.com/demos/olcPGEX_MiniAudio/demo_waveform.html).
* [Synthesis Demo](https://www.moros1138.com/demos/olcPGEX_MiniAudio/demo_synthesis.html).

# This is an olc::PixelGameEngine Extension

Expand Down Expand Up @@ -47,9 +50,20 @@ Cross-Platform, out-of-the-box. Easily use in your Linux, Windows, MacOS, and Em
* Get the current position in the sample, in milliseconds.
* Get the current position in the sample, as float 0.0f is start, 1.0f is end.

### Waveform Features
* Create sine, square, sawtooth, and triangle waves.
* Load and play multiple waveform channels at the same time.
* Modify waveform amplitudes, frequencies, and types in realtime.

### Noise Generation Features
* Set a callback function to send and play raw audio data for potential sound synthesis.
* Send raw data for both left and right stereo channels.
* Track passage of audio frame time for oscillators / time-sensitive applications.

*** Advanced Features, for those who want to use more of miniaudio
* Get a pointer to the ma_device
* Get a poitner to the ma_engine
* Get a pointer to the ma_engine
* Get pointers to waveforms and sounds

# Usage

Expand Down Expand Up @@ -109,3 +123,5 @@ That's it!
# Acknowledgements

I'd like to give a special thanks for JavidX9 (aka OneLoneCoder), AniCator, JustinRichardsMusic, and everybody else who was a part of that audiophile conversation when I asked for help! Your patience and feedback made this project possible. Thank you!

I'd also like to single out sigonasr2 (Dense Dance 2π) for the waveform functionality and for crafting the demos for them!
39 changes: 33 additions & 6 deletions demo/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
INCLUDE := -I../ -I../third_party/miniaudio -I../third_party/olcPixelGameEngine
GCC_FLAGS := -std=c++17 -O2 -lX11 -lGL -lpthread -lpng -lstdc++fs -std=c++17 -ldl -lm
EM_FLAGS := -std=c++17 -O2 -s ALLOW_MEMORY_GROWTH=1 -s MAX_WEBGL_VERSION=2 -s MIN_WEBGL_VERSION=2 -s USE_LIBPNG=1
GCC_FLAGS := -std=c++20 -O2 -lX11 -lGL -lpthread -lpng -lstdc++fs -ldl -lm
EM_FLAGS := -std=c++20 -O2 -s ALLOW_MEMORY_GROWTH=1 -s MAX_WEBGL_VERSION=2 -s MIN_WEBGL_VERSION=2 -s USE_LIBPNG=1 --shell-file shell.html --preload-file=./assets@assets

.PHONY: all linux emscripten clean

Expand All @@ -9,12 +9,39 @@ all: linux emscripten
demo: demo.cpp
g++ demo.cpp -o demo ${INCLUDE} ${GCC_FLAGS}

demo_synthesis: demo_synthesis.cpp
g++ demo_synthesis.cpp -o demo_synthesis ${INCLUDE} ${GCC_FLAGS}

demo_waveform: demo_waveform.cpp
g++ demo_waveform.cpp -o demo_waveform ${INCLUDE} ${GCC_FLAGS}

demo.html: demo.cpp
em++ demo.cpp -o demo.html ${INCLUDE} ${EM_FLAGS} --preload-file=./assets@assets
em++ demo.cpp -o demo.html ${INCLUDE} ${EM_FLAGS}

demo_synthesis.html: demo_synthesis.cpp
em++ demo_synthesis.cpp -o demo_synthesis.html ${INCLUDE} ${EM_FLAGS}

demo_waveform.html: demo.cpp
em++ demo_waveform.cpp -o demo_waveform.html ${INCLUDE} ${EM_FLAGS}

linux: demo
linux: demo demo_synthesis demo_waveform

emscripten: demo.html
emscripten: demo.html demo_synthesis.html demo_waveform.html

clean:
@rm -f demo demo.html demo.js demo.wasm demo.data
@rm -f \
demo \
demo.html \
demo.js \
demo.wasm \
demo.data \
demo_synthesis \
demo_synthesis.html \
demo_synthesis.js \
demo_synthesis.wasm \
demo_synthesis.data \
demo_waveform \
demo_waveform.html \
demo_waveform.js \
demo_waveform.wasm \
demo_waveform.data
Loading

0 comments on commit 04b66f3

Please sign in to comment.