Android: synchronization of Audio, images and text in a Media Player, - android

I would like to know how I can synchronize an mp3 file, a text box and images (mp3, text and images must be received via http) that is will be displayed on a video player which must receive and show the images every 10 seconds, and likewise have a text box with the synchronized audio and therefore with the images (showing the text of the mp3), I have researched, but i not know where to start, how to manage the intervals and the data, with methods as "timer" in c #, really would appreciate your help.

I am assuming the text and the images have TimeStamps associated with them. (TimeStamps - Time at which they should be displayed relative to the audio), if so then you can do this
Play the audio file using the MediaPlayer class
Use the method getCurrentPosition() to get the time value
Based on the time above check if you need to update the image or the text or both, if you need to then update TextView and ImageView

Check out the CountDownTimer class provided in the android sdk to manage the intervals: http://developer.android.com/reference/android/os/CountDownTimer.html
As for getting images via http here is a simple java tutorial on sockets: http://docs.oracle.com/javase/tutorial/networking/sockets/

I resolved that with:
if(mediaPlayer.isPlaying() && abc >= 313800 && abc < 379340){
currentimageindex=6;
subtitles.setText(this.getString(R.string.t7));
I hope to help others.

Related

Android : How to Get the amplitude and Frequency of a sound in a .wav file at particular Second

I am working on an Android Project in which ,
Let's Say I have an audio file in .wav format
I want to create an array in which i want to set three fields :
1. Time (in Seconds or in Mili Seconds) of audio file.
2. Amplitude at that particular Second of audio file.
3. Frequency at that particular Second of audio file.
I am thinking that i can use "for OR while" loop to create the array by getting amplitude and frequency at each second and save add it to my array list.
But I don't know how to get the value of amplitude and freuency at that particular Second from my audio file.
I never worked with audios before, So I don't know , Is there any method to get these values.
I am thinking that as amplitude can be represented on graphs of amplitude and time, amplitude can be an integer or long ( I actually Don't Know ).
Is it possible ? If Yes than How can I achieve this.
Thank You In Advance :-)

How to save images by name as 1,2,3,....n in android

My app contains the camera functionality. I have develop the app.
As the app get starts one ListView of stations will popup(Like Station1, Station2,Station3....) & user has select one item from it. Then it will open the camera activity. So once the user took a picture, the image has to be stored like 'Station1_1', 'Station1_2', 'Station2_1', 'Station2_2' inside gallery. I have covered with the initial station name(Station1, station2..). But how do I store the last portion because it contains the sequence for each Station. So is there any way to save the images by 1,2,3....?
Thanks in advance.
There is a way but it isn't appropriate. If you just want to store each image having last portion is different then you can do in the following ways:-
You can call API for just handling counter.
You can store counter in PREFERENCE, but it won't work perfect if user clear data then new images were override old one.
You can store TIMESTAMP as end portion and it is appropriate way.

Android Text to Speech add speech text continuously

I'm currently developing an app for visually impaired people which will read .txt files. I'm thinking about loading texts in blocks with i.e. 50 chars, that will be something like "page". The problem is how to connect those "blocks" in TTS. I'm using method Tts.speak(speechText, TextToSpeech.QUEUE_ADD, null) and between blocks there is always a space. It's annoying when the word or sentence (because of intonation) is divided with speech space. Isn't there something like "stream" that allows to add speech text to tts continuously and that doesn't give speech spaces?
I know I could divide the text not into pages but to sentences, but not all texts are in sentences so I would have to define some good way how to divide the text. The solution with blocks with same count of chars seems better to me now.
Have you tried to initialize a new TextToSpeech for every 50 chars and start it when the first ends?
Did you define, for example, two different TextToSpeech variables correctly initialized? and though:
1) First 50 chars added to the first queue and at the same time the second 50 chars added to the second queue;
2) When the first queue ends to reproduce start the second one end rewrite the first one with the third 50 chars;
I think you should not have some delays. They are necessary when modify one queue but if you will start a new one it should be immediate.

How to do Visualizer while recording audio in android

I know Visualizer to show some wave while playing audio using android Media Player.
But i want to show Visualizer while recording audio means while recording i want to show linear wave which changes based on user voice beat.
Is it possible to do in android.
by calling every x milliseconds your MediaRecorder.getMaxAmplitude(), you gonna have (from official documentation) :
the maximum absolute amplitude that was sampled since the last call to
this method.
then, you can process this value in real time to draw a graph or change some view properties.
not perfect, but I hope it helps =)
edit: just so you know, the retrieved value will be the same across all android devices : between 0 and 32767. (I have more than 10k user's reports giving me this value when they blow in the mic).
You may need to use AudioRecorder class instead of MediaRecorder.
Check AudioRecorder#read(...) methods which put audio data to byte[] instead of putting it directly to a file.
To show changes on the graph you will have to analyze the data (which is encoded in PCM 8 or 16 bit - link) and update the graph in real time.
Two important things:
you need to convert live bytes (from mic) to numeric values inorder to plot them.
Since you use a real-time graph, to plot those points
use SurfaceView.
Convert recording bytes to numeric values refer:
Android: Listener to record sound if any sound occurs where you will see the variable "temp" holds the numerical value of your audio.
Plot points
These numeric values which indicates your Y values is plotted against increasing X (time interval) values (0,1,2..) as graph. Using SurfaceView
eg..,
//canvas.drawLine(previous X value,previous Y value,X,Y, paint);
canvas.drawPoint(X,Y,paint);
SurfaceHolder.unlockCanvasAndPost(canvas);
You need not plot all values, for efficiency you can filter those values with your conditions and plot for certain intervals of time.
Hope this helps :)

Convert text into symbols, then convert symbols into sound

I'd like to know how to let a user input text ex. "TEXT", then have my app convert that "TEXT" into something like "#&^#", then have my app recognize "#&^#" as 4 different letters, ex. "#" "&" "^" "#", then play that letter's sound. I have recordings of each letter's sound.
ANY help will be very much appreciated.
First, create an app with an EditText.
Then create a listener which detects when a user has changed the text.
In that listener....
retrieve the text
Convert it into your symbols
For each symbol, play the appropriate sound. You'll need to implement something that queues them in order, so one starts playing once the last has finished.
I suggest you tackle these one step at a time, asking one question on this site for each of the above points.

Categories

Resources