-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
macOS / iOS sound player. AVAudioEngine - WIP #6728
Conversation
Looking good!! |
Hi, I have several of this features, and more, working on ofxSoundObjects. it only relies on dr_wav, dr_mp3, dr_flac and stb_vorbis, to load the files. I think that having an approach as this would allow to have a more unified sound engine, where you could be able to manipulate audio data from a sound file in the same way as you can with a sound input. The current audio resampling of ofSoundBuffer is not good. I have also implemented using libsamplerate and works really well. I could add a bunch of optimizations as using SIMD as ofxPDSP does. I think that this implementation would be a lot cleaner than having a different one for each platform. |
@roymacdonald couple of questions about ofxSoundObjects
I have to update this PR but I basically have everything except getSpectrum / fft working. |
Hi @ofTheo
ofxSoundObjects use ofxAudioFile as the backend for loading files. So far it supports Wav, mp3, FLAC and Ogg Vorbis. But adding a library for m4a does not sound like much of a problem.
I think that it would be reasonable for me to make a special branch before adding into OF because there is useful things than can be extracted from the different branches. ofxSoundObjects has an example that runs an fft, so adding the getSpectum part to the player is not much of a problem. And running benchmarks to compare with "native" players should be also done. I would be super happy if we merged ofxSoundObjects into the OF core. Let me know what you think so I can work on it to make it mergeable. BTW, I also have ofxSoundObjects working with ofxAudioUnits and ofxNDI. |
@roymacdonald nice that it doesn't need any libs compiled!
I'll give it a spin and try it with the soundPlayer example. Which branch would you recommend? |
Certainly. I will look at such.
go with the master branch. experimental has more features, but the core of it is pretty much the same. Currently you need to set up the player along with the sound stream, etc. but It is quite straight forwards to implement something that behaves exactly as the current ofSoundPLayer. I mean, no need to setup the sound stream, connect to it, etc. The one thing I think would be very important to update/fix in order to make this all work nicely is to properly implement the ofSoundBuffer resampling, which can be quite tricky and currently does not work nicely. I found out that the best approach is to use a library for such, like libsamplerate. |
this is great news @ofTheo and @roymacdonald |
Just wondering here @ofTheo if this could be merged as it is, and improved by PRs later. |
@dimitre I think I have a few local updates I need to push, but then might ask @2bbb @danoli3 and @roymacdonald to take a look. The FFT stuff should be doable natively, but after a couple of attempts I might ask people with better knowledge to take a look. |
Hi @ofTheo i have been extra busy recently but I can take a look at this during the week. I will let you know. |
Just updated this - it still needs FFT.
Would be great if someone who has a better idea of One nice thing it does handle well is switching audio outputs while its playing. |
Hey @ofTheo I'll test this one today and made some changes to make it work with ARC, not sure if they are correct. |
Thanks @dimitre !! |
- (BOOL)isLoaded; | ||
- (BOOL)isPlaying; | ||
|
||
- (void)volume:(float)value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a small part, getter/setter method in basic obj-c style is
- (void)setVolume:(float)value;
- (float)volume;
then we can use property style access like
obj.volume = 0.5f; // equivalent to [obj setVolume:0.5f];
float v = obj.volume; // equivalent to float v = [obj volume];
|
||
@implementation AVEnginePlayer | ||
|
||
@synthesize timer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
basically, no need to explicit @synthesize
if we use timer as self.timer
(or _timer
on internally. _timer
will be defined automatically with @prorpety
declaration).
if we want to use simply as timer
then @synthesize timer
is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@2bbb thanks for these suggestions.
To be honest I know very little about Obj-C. If you wanted to fork this branch and do a PR with Obj-C fixes would be more than happy to close this one :)
One thing I really miss compared to default ofSoundPlayer is the capability of playing audio backwards setting a negative speed. I've noticed the values are clamped but probably varispeed doesn't allow negative speed or maybe it is other property. I've noticed a while ago the same thing in @admsyn ofxAudioUnit. Maybe looking at ofxAudioUnit can be helpful for fft too |
Heyy I think this should be merged soon, so it is easier for all to make PRs on the top of the existing code.
|
Will need Objective-C++ filename of .mm instead of .m |
Yeah @danoli3 I've did that in my fork |
Awesome yeah I've been testing it out tonight! Looks and works great! I'm testing in the ARC branch however just with "-fno-objc-arc" currently on this .mm! I think this is production ready |
…re / epsilon float compare fix (cherry picked from commit 299f3e5)
… - Fixes Crashes and Hangs due to thread locks due to old use of old AVEngine that system destroys / terminates access to hardware / Fixes AVAudioSessionCategory issues
I would love to see this merged, even if incomplete. I don't think it will interfere with any other OF functionality. |
Thanks!
There are definitely some things in there that I’m not sure I quite understand correctly. :)
|
Working pretty well right now, solves most issues / resume / audio interruption events (restore audio engine / hardware connection fixed) / allows sound to play with phone silence button on by default now with new AVAudioEngine (apple control this). Some minor changes to push |
Awesome @danoli3!! |
Heyy let's merge this one! |
reverting this as there is too much to fix in master to get this working. |
Now re-opened as #7293
Addressing #167
Features:
ToDo:
Questions: