I'm writing an accompaniment application that continuously needs to play specific notes (or even chords). I have a thread running that figures out which note I need to play, but I have no idea where to begin regarding the actual playback. I know I can create an audiotrack and write a sine wave to it, but for this project a simple tone won't cut it. So I'm guessing I either need to use MIDI (can android do that?) or to somehow take a sample and change its pitch on the fly, but I don't know if that's even possible.
All I can say is to check out pitch-shifting (which you seem to have heard of) and soundpool (which would require some recording of your own) and these 2 links:
Audio Playback Rate in Android
Programmatically increase the pitch of an array of audio samples
the second link seems to have more info.
Related
I'm trying to write a simple "drum-machine" type app. in Android. Currently I'm prototyping it in Processing.
I'm looking for the way to play audio sound samples using the Android SDK.
In particular I need :
to play the sample in a separate thread, so that it doesn't hold up the main UI thread
to be able to play multiple samples simultaneously
to be able to play the same sample simultaneously (eg. if a particular sound has a longish decay, to be able to launch a new version of it while the other is finishing)
NOT to have to have the overhead of loading the audio file, creating and instantiating a player object each time I play the sample
I've read a bit about AAudio, but I need to work on older versions of Android (ideally back to 4, but at least 5)
ideally I want to do this in Java, not have to fall down to using the ndk if I can possibly avoid it.
So I'm thinking I want to load my samples into buffers in memory, have some kind of pool of "player" type objects, each of which can iterate through the buffer independently, in their own thread, while sending to a common audio stream.
Any idea what I should be using for this.
Most of what I found seems to be monolithic "audio player" type objects which do everything from loading and playing an audio sample when invoked. I think I'm looking for lower-level components than this. But I'm not sure where to look for them.
I am newbie in android developing, I have searched for this question but i didn't find my answer.
I want to know is there any ability to edit the sound calls in android?
I mean i want to add noise or change sounds of caller, Is it possible to change the sound in calls or adding a new sound to it?
TL DR : The answer is not yet.
And it's not like we've been waiting. The first entry i can find is from July 31 of 2009, the issue #3434 and, as of today (May 13 of 2015) it's still has not been assigned.
It's really hard to actually work on low-latency project, audio recording and of course, voices changers when you can't do low latency.
Not to say there's hasn't been any workarounds, you could emulate yourself the call, and add the voice effect sure (build your own dialer, and work with that), but let me warn you : you probably won't have any good perfs when it comes to real-time appliucations. No low-latency means no efficiency when it comes to audio recording.
You'll have to wait then.
Your question can be resolved partially depending your using model. the premises are :
you just want to eject some noise into your outgoing audio stream,
not into the incoming audio stream.
you may use a third-party VoIP application to make the phone call.
or simply say, you just want the peer to hear some modified voice. it is feasible.
Normal a native phone application on Android platform uses "Android audio system module" in the framework, the vendor provided audio libraries and Linux ALSA audio libraries to transmit/receive the audio data. These .so and .a files are under the read-only mode normally and could not be overwritten by user, so you can not inject data into this data chain.
But you have more capability to manipulate the data if you use a VoIP application to make the phone call, some VoIP applications can give a real phone number, like Fongo, you can receive a phone call to that number, the caller does not know you are using a VoIP application to speak.
So if I was assigned to do this project, here are my steps:
find a usable and open sourced VoIP client on Android.
find the code to sample the audio data from microphone ,add the code
to manipulate the raw PCM data and send the result to audio encoder.
build and run it on Android
register or apply a phone number for this VoIP client.
done.
Hope it help
I'm currently developing simple video player with VLCJ.
Can anyone please point me some clue about changing audio pitch with it?
is it possible?
I've searching through but cannot find the right keyword, what i need is
some control (method/function) of vlcj (or any) to increase sound so it sounds like
kids voice, or lower down so make like a very old man sound.
Thanks in advance.
NOTE:
still looking on google but found nothing about vlc. what i want is something about the "timbre" as explained at http://www.screamingbee.com/support/morphdoc/MorphDocPitchTimbre.aspx
If you are only interested in playing audio (you don't care about displaying any video at the same time) then vlcj 2.4.0 and later provide a so-called "direct" audio player component.
With this component, your Java application can get direct access to the native audio sample buffer. You can run whatever algorithm you want on those samples, then play out your modified samples via JavaSound or some other API.
There is a sample included in the vlcj distribution that shows how to use this component to play via JavaSound:
https://github.com/caprica/vlcj/tree/vlcj-2.4.1/src/test/java/uk/co/caprica/vlcj/test/directaudio
The example does not show how to change the pitch of the audio, but it does show how to use the direct audio player.
I have made a few simple apps on android, and thought it was time for something a bit more complex. So, i thought I'd try something that's already out there, but build it from scratch.
The idea is to create an app that allows user to play piano by pressing virtual keys on the display. But I'm not sure how to go about synthesizing the sound of each note, is it best to have copies of of each note stored on file, or is there a more dynamic way of synthesising notes and chords on the fly.
I have worked with C++ so NDK stuff is also okay.
Thanks for any help.
Sound playback (handing off buffers) pretty much has to be done from the Android java apis
Synthesis could be done in native or java, whichever it preferred.
Short (uncompressed) samples could be played back repeatedly, but you probably also want an attack transient. Perhaps you could have an attack, a sustain, and release, repeating the sustain as long as the key is down. Ideally each sample should be an integral number of periods of its fundamental component long so that you don't get a transient when you change between the attack to sustain or sustain to decay.
I'm sure you can find code somewhere for an FM or other synthesizer... this you might well want to implement in a native library that hands off buffers to java code to pass to the audio apis.
What is too bad is that android already has an internal midi synthesizer, but apparently lacks a dynamic interface to it, so it can only play midi files.
By far the easiest solution would be to record the sound of each note on the piano and play it back when the key is pressed. Many professional virtual piano instruments work this way, recording every note on the piano being played at multiple velocities. Obviously this can take many gigabytes of disk space, but for a mobile phone app, you might get away with a single MP3 recording of each note in an octave.
Actually algorithmically synthesizing the sound of a piano is very difficult to do, and until fairly recently, very few have done it convincingly (pianoteq is one of the best current implementations).
I would like to write an App, that picks up sound from the mic, adds effects to it and plays it back in realtime.
If found AudioRecord to pick up sound from the mic and AudioTrack to play it back. In between, I need some library to manipulate the sound, add effects or use some equalizer on it. This maybe achieved with the Java Sound API, but that seems to be missing as I read in this issue report pointed to from this SO question.
My question is: How can I do this on Android? Can you recommand any libraries?
Quick google search http://developer.android.com/reference/android/media/SoundPool.html. It seems you can add effects using this class