Blackberry How to play sound (short[]) using the speaker of the device? - blackberry

I am using Alert.startAudio to play an array of short values,
I want the same short[] to be played using the phone speaker, how could I do this ?

I believe it is played with speaker by default!
But if it's not, try to use AudioPathControl
See BB KB How To - Specify Audio Path Routing
UPDATE
BB Developer Journals - The BlackBerry Alert Class:
The next two methods will start and stop an audio alert on the audio channel selected by the user. An audio channel can be the internal headset, speaker, earpiece or a Bluetooth® headset.
maybe this should be configured somewhere in device...

Related

Recording voice while playing music - filter speakers input (iOS)

I am developing an Karaoke app in which you can record your voice while listening to the music. When user uses headphones, everything is great - he can listen to the music and himself in headphones while singing. Then we have his pure voice recorded and we can mix it with playback.
Problem occurs when user does not use headphones. Then we play music via speakers AVAudioSessionCategoryPlayAndRecord and record simultaneously. In final recording we have user's voice and playback from speakers mixed together. Problem is that playback's volume is very big and it's "covering" user's voice. Firstly I thought that this is normal behaviour because speakers are close to microphone so there is nothing I can do.
However when I tried the same thing on Garage Band it somehow lowers playback from speakers making voice more hearable.
I also tried it with Instagram (you can record while playing music e.g. from Spotify) and I noticed that after ~1 sec. playback's volume is decreasing and we can hear voice more precisely.
I don't think that it's post processing because it would be very complicated so maybe there is an option to let "iOS handle it".
To be clear - it does not lowers playback during recording - it's "done" while listening final video.
I use AVCaptureSession for recording and AudioKit Player for playing.
Thanks in advance for any thoughts/tips/advices!
Regards
Ok so I asked Apple TS and the respond was exactly what I wanted: https://developer.apple.com/documentation/avfoundation/avaudiosession/mode/1616455-voicechat You just have to set this mode in AVAudioSession and system will handle it device’s tonal equalization is optimized for voice
iOS cannot 'just handle' that, there is no "filter out the music" function. The fact that it doesn't do it live, but does so later or with a delay strongly implies they are doing some post processing. I'm not a machine learning expert, but I think if you just used an equalizer and a noise gate you could get this effect. It'd be hard to extract an acapella but you could certainly improve it. Likely Instagram takes that second to identify where the voice frequencies are so it knows how to EQ the signal.

Routing audio to both built-in speaker and bluetooth headset simultaneously in iOS

I'm simulating an incoming call notification by playing an audio file through AVAudioPlayer. I wish to play the audio to both built-in speaker and connected bluetooth headset simultaneously.
I tried using AVAudioSessionCategoryMultiRoute and AVAudioSessionCategoryPlayAndRecord with AllowBluetooth category option selected.
For AVAudioSessionCategoryMultiRoute, it is not able to detect the bluetooth device in available outputs.
For AVAudioSessionCategoryPlayAndRecord, audio is routed to either bluetooth or speaker depending on the category option passed in while setting up the audio session category.
Is it possible to route the audio to both built-in speaker and bluetooth device simultaneously using AVAudioSession API? Any code snippets, if available?
Looking at the documentation of AVAudioSessionCategoryMultiRoute it states that (emphasis added by me)
The category for routing distinct streams of audio data to different output devices at the same time.
Meaning that you can only output different audio streams to different output channels. You cannot output the same audio stream to several channels.
As far as I'm concerned, there are no other methods to achieve playing the same audio stream on several channels either.

Intercept/modify audio stream on iOS

I am looking at the feasibility of getting the current raw audio stream playing and do stuff with it such as stream it over Bluetooth or equalize it, etc. Is there any way to do this in iOS 8?
For example: apps such as Pandora/Spotify are playing music and I want to access the audio they are playing.
To process audio from another app, that app needs to participate in Inter-App Audio.
I don't know if your example apps do that.

Can I use AVAudioRecorder with an external mic?

Sorry if this question is obvious or duplicated. My 30 minutes of research led me nowhere.
We have an iPhone app that live streams video from the device to our remote Wowza servers.
We're looking to integrate the Swivl (motion tracking tripod) into our product, and it uses a wireless microphone that feeds into the 30-pin port of our iPhone. Swivl's SDK doesn't include anything about capturing audio from their hardware so I assume that it would be handled by the iPhone itself.
If I use the AVAudioRecorer, will it automatically route the audio input from the 30-pin port instead of the default microphone, or do I have to explicitly define the audio source?
Any clues help.
After a few tests, it seems that iOS automatically routes incoming audio signals.
There is no need to explicitly specify the source of the audio.
Straight from AVAudioRecorder documentation:
In iOS, the audio being recorded comes from the device connected by the user—built-in microphone or headset microphone, for example. In OS X, the audio comes from the system’s default audio input device as set by a user in System Preferences.

Intercom with Bluetooth headset

I've been researching the ability to create a bi-directional audio link between iOS and a bluetooth audio headset.
What I need to be able to do is:
When the user speaks into the microphone on the iOS device, that audio should be redirected to the audio out of the headset, the piece.
When the microphone of the headset picks up audio, that should come out the speaker of the iOS device.
In my searching I've found that you can:
Enable bluetooth audio input and output:
how to route iPhone audio to the bluetooth headset
Redirect input to speaker:
Mic input to the speaker output on an iOS device?
After reading this:
AudioSession input from bluetooth output to line out or speaker
I'm thinking what I want to do cannot be done.
So before I get to testing, does anyone know if what I'm trying to do is even possible. From the last link it appears you can only have one input and output pair at a time. What I'm trying to do would require two pairs of input and output. In from BT, out to iOS speaker. In from iOS Mic, out to BT.
Thank you!
The current public iOS Audio Session APIs appear to only support a single audio route pair (input+output).

Resources