Comments (5)
I guess that it is because the sound is stopped before reaching its end. Would it be possible to have a callback when sound is being stopped?
from miniaudio.
I didn't think a stop callback would be needed because since you just passed the details into the ma_sound_stop_with_fade_in_pcm_frames()
function don't you already know when the sound is being stopped?
from miniaudio.
Practically it would be quite complicated to deal with the time used in ma_sound_stop_with_fade_in_pcm_frames
.
Maybe I should explain, why I wanted it. I am working on an integration of your lib to Rebol (scripting language). So far the sound is initialised in a memory, which is managed by Rebol. Rebol is using GC. When the sound handle is not referenced, it may be released. On release I call ma_sound_uninit
.
Its is ok, when used in (Rebol) code like this, because there is the song
reference:
song: play/stream %my-song.mp3
But when user would use just:
play/stream %my-song.mp3
there is no reference to the sound and when GC would be evaluated, the sound would be uninitialised and so not audible anymore. Trying to resolve this situation, I lock the Rebol sound handle when the sound is started (so it would not be GCed) and unlock when it is stopped. It is working except the case when the sound is stopped with the tween. It could be simulated in Rebol in code like:
stop/fade play/stream %my-song.mp3 0:0:10 ;; the song is faded out in 10s
In such a case the end callback is not fired and the handle is locked even when the song is not used and referenced anymore. I am aware that it is an edge case, but it is possible.
from miniaudio.
I'm not necessarily against this or anything. But there's a problem - I've changed the API for sound notification stuff in the dev-0.12 branch and I don't want to be adding this to 0.11.x only to break the API when I get 0.12 out. So if I do this, it won't be in before I release 0.12 which might be a ways away (no time frame).
I'll leave this open and mark it as a feature request.
from miniaudio.
I think it is ok.. when playing a little bit more with your library, I think that having the stop callback would not be enough anyway... I must do a little bit more advanced memory management to deal with miniaudio resources... for example I must have some connection between ma_sound
and data sources like ma_noise
and so on. I also need some time to figure it out.
from miniaudio.
Related Issues (20)
- Only white noise type is generated HOT 4
- number of requested sample by callback HOT 1
- Fade is not working if sound has current volume equal zero HOT 2
- ma_sound_init_from_data_source complete example HOT 3
- Unused function warning when compiling miniaudio_split/miniaudio.c HOT 3
- Mutex Issue When Resuming Android App HOT 8
- 2 error when compiling on android HOT 6
- How to compile for WASM?
- Help or guide on building as a shared library, specifically for use with managed languages like C#, especially on WASM HOT 1
- Cannot compil with latest emscripten and MA_ENABLE_AUDIO_WORKLETS (3.1.45) HOT 2
- Is it possible to "push" audio to a device, like SDL_QueueAudio? HOT 1
- Setting `sampleRate` to zero causes AudioContext creation to fail when compiling for WASM. Is that expected? HOT 5
- miniaudio just doesn't work HOT 2
- Getting undeclared identifier error when attempting to compile example code. HOT 2
- Atomic operation failed right after initialization on Apple Mac M2 HOT 2
- OSX ma_context_init__coreaudio fails to open dylibs HOT 7
- Adding Vorbis in split version HOT 4
- Add possibility to work with signed 8-bit data HOT 1
- 3D Sound Coordinate System HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from miniaudio.