PCM buffer - Android Software Development

Hi All,
Not sure if this is the right forum so please move if not...
I am trying to write a voice changer for android and I'm running in to some design decisions which I need a little help with.
I am using AudioRecord to get PCM audio from the mic, I need to record audio until the audio is below a certain level, I am then going to perform some processing on it and play it back. So I am unsure how long the audio is going to last for.
Since I want the delay between recording and playback to be as small as possible, I am unsure whether to keep the buffer in memory or to write it to the SD card and process it from there.
How much of a delay would using files induce when I am doing a lot of processing on the signal?
I am sampling at 8000 Hz so presumably 1s of audio would take up 1.6K of memory, what's the practical limit on the amount of memory I can use within the app?
Thanks

Related

R2 generic UK video rec

Does the new FW improve the quality of sound when recording video?
As I posted long time ago and never get any solution - the sound of the video is always strangely deformed,
WHILE when recording a sound note - it's fine!!!
Is it dependend on any setting OR the fact of storing video on memory card directly?
I actually never had this problem. What ROM are you using? I don't think it's caused by storing it on the storage card.. I mean, how the hell would that alter sound quality?
Try messing about with the settings a bit and also check what apps you installed, perhaps some codec got messed up a bit?
Haven't tested it, but, I would imagine that the bitrate used when recording video (128 kbps ?) is far inferior to the bitrate used while just recording audio only (>1000 kbps ?). Bitrate alone makes a big difference in sound quality.
Hmm
I havn't used it on older ROMs but hae taken quite a few vids of a robot I have been building over hte last few days and it has been fine, although the sound was mostly of myself and my team laughing and shouting, even the very loud sounds didn't clip or anything.
alias
Thanks for reply.

Problems with Music Playback on the HD2

Hello!
I have searched now for several hours in different forums and many threads, but I did not find my specific problems or any solutions to them. Therefore I want to start a new thread.
One thing in advance: I have my HD2 now for about 3 weeks and generally I am very happy with it. Unfortunately, I am experiencing some really bothering problems with music playback, and as this is the second most important feature to me (after telephony), I really hope, that there is some solution out there.
1. According to some Internet pages the integrated music player of the HD2 should be capable of gapless playback of MP3 files since a software update. Well, I have installed the latest 1.66.xx ROM for my device, and unfortunately gapless playback does not work at all. When I am listening to a concert and one track ends and another starts, I always hear a small interruption in the applause. When I play back the exact same tracks on my PC with Winamp everything works fine and both tracks play back to back without any interruption at all. As far as I know Winamp prebuffers approx. 2 seconds and in my opinion for gapless playback the integrated music player of the HD2 should too, but obviously does not.
2. Especially when I am listening to tracks with a quite low volume (e.g. instrumental Soundtrack), I always hear a short "crackling" sound at the transition from one track to the next (or at the beginning of the new track). One forum entry claimed, that this "crackling" sound is caused by the fact, that the HD2 disables the headphones output after approx. 2 seconds of silence and just reactivates it again when there is sound again. The reactivation of the headphones output seems to result in the "crackling" sound.
3. I thought that I can get rid of both problems just by using another player software as alternative, I even bought one of these. I tested "Microfi Nitrogen", "MortPlayer", "Slide 2 Play" and "PocketMusic".
Using the "Cross Fade" mode of "PocketMusic" in fact solved the first two problems effectively, so I got gapless playback without a "crackling" sound between two tracks.
Unfortunately, with all of these alternate players I experienced one even more bothering problem: Every now and then (approx. 1 to 2 times per minute of playback) a short "clicking" sound is audible during playback, which reminds of an scratched vinyl disc. If I rewind the track, the "clicking" sound does not occur at the same position, but at another at a later time. These "clicking" sounds do not occur at all with the integrated music player of the HD2, but with ALL of the mentioned alternate music players I tested. Of course, the "clicking" sounds are audible better, when you are listening to instrumental or classic music with a relatively low volume than with loud Rock or Heavy Metal music tracks.
To avoid the obvious suggestions:
- The problems were already present with the 1.48.xx ROM and are still present with the 1.66.xx ROM.
- I tested several different headphones (cheap and expensive ones) including the original HTC ones which shipped with the HD2.
- I can rule out the MP3s as cause of the problems: There are absolutely no problems with them when they are played back on the PC with Winamp, a Sony-Ericsson phone, an iPod or when played back with the mentioned alternate players on Pocket LOOX N110, N120 (Prototype), 420, N500 and N520.
- It does not matter whether the MP3s are located on the internal memory of the HD2 or the SD card.
- I already tried to disable all data connections on the HD2 and closed all other programs using the Task Manager to avoid any interferences.
- I even performed a Hard Reset without installing additional software or tweaks (except for one of the alternate players).
- I tested "PocketMusic" with all possible settings regarding Cache, Buffer Priority etc..
- It does not matter, whether any Equalizer (if available) are enabled or not.
- I also tested my brother's HD2, and both devices - my own HD2 and my brother's HD2 - show the same problems.
My questions now are:
a) Can anybody verify the "clicking" sounds when using an alternate music player software? If not, which music player software do you use at which settings?
b) Is it possible somehow to disable the interruptions between two tracks with the integrated music player of the HD2 and thus enable true gapless MP3 playback, for example by an undocumented registry setting regarding (pre-)buffer size or Caching?
c) Is it possible to disable the deactivation of the Headphones output after some seconds of silence (which is said to cause the "crackling" sound), so that the Headphones output is always enabled when there is playback using the integrated music player of the HD2, for example by a Registry setting?
Generally, I would love to continue using the integrated music player of the HD2 (which I am doing now anyway, and it looks really nice, by the way), but the missing gapless playback and the "crackling" sound during the transition of tracks is really bothering me very much.
Many thanks in advance for your help!
DotWin
I dont get the crackling sounds you speak of but it is a little off putting when I'm listening to a non stop mix CD thats broken up into tracks, when a track abruptly ends it's followed by a half second silence only to head right back into the music.
Is there some registry tweak that we can use to either eliminate this gap or even shorten it?
I use Coreplayer, and it seems they screwed up the standby keepalive at least on the HD2. With BT headphones, if I start music and then turn the screen off with the power button, I'll start getting random skips. With wired headphones ith completely stops playing music. So I've bound long press windows key to "turn screen off" in AEBPlus, and I now have no more problem with that (when I remember to press that one instead of the power button, that is...). Works perfectly, never heard a skip anymore (I have a set of Sennheiser PX200II, way good enough to make anything noticeable )
Your problems with 3rd-party players could be linked, no idea...
Not sure about the crackling, as I listen to music for at least 2 hours a day on the way to work and I use a pair of Sennheiser HD-25 headphones (http://www.sennheiser.co.uk/uk/home...onal_headphones-headsets_dj-headphones_502188) and I don't hear any crackling between tracks or in periods of silence. Only hear vinyl crackle where the source for the MP3 is vinyl.
The lack of gapless playback, as jmwarren85 mentioned is really annoying as I listen to a lot of mix albums... one solution I use is to take all the MP3's from that disc and splice them into a single track and then listen to that on the HD2.
Also finally I can't say I have heard any clicking noises on my HD2 but I know what sort of clicking you are referring to and that may be due to the encoder used and/or its settings when the MP3's were encoded. Some of the codecs that players use for decoding MP3's aren't the best (ie not well optimised, which can especially be a problem on a mobile device) and you occasionally get audio artifacts.
I use LAME with VBR-0 with quality 0 (highest) and the minimum bit rate of 128 and maximum bit rate of 320 using 44.1kHz instead of 48kHz for compatibility and I don't seem to get any problems.
Hope this helps...
Hi!
Thank you for your messages!
After extensive testing, I have finally bought "Pocket Player" which has solved all of my problems.
But I still think, that the integrated player (which at least looks great) has some bugs in the audio department that should be fixed.
DotWin
DotWin said:
Hi!
Thank you for your messages!
After extensive testing, I have finally bought "Pocket Player" which has solved all of my problems.
But I still think, that the integrated player (which at least looks great) has some bugs in the audio department that should be fixed.
DotWin
Click to expand...
Click to collapse
Hello there.
The crackling you've described may be in relation to network use, for example every time my phone uses the 'net connection (HSDPA) to get weather, location or email, the audio stops for a brief second and continues; this is almost like the crackle you describe.
This in turn disables the graphic equalizer, so I am regularly re-enabling this between songs or in the middle of songs.
Test the theory by putting your phone in airplane mode or disabling all data reliant services to see if this is the issue. Even if it is I can't offer a fix, but at least you know what the issue is at least with the built in HD2 audio app.
I have the exact same issues as the OP. I contacted HTC about the gapless playback and they said they're testing...
I hear a soft/small pop between tracks too when I'm using headphones.
I also sometimes experience another issue where sometimes instead of going to the next song after finishing the current one, it just stops. Time remaining shows 0 secs, it's 'playing' (pause button is shown) but it doesn't move on.
I know it's a little late to reply to this post, but it was just to say that you can remove the gaps between the tracks using Ogg Vorbis encoding instead of MP3 encoding. Winamp for Android can read ogg tracks
About sound quality, there is always a quiet background interferences noise that bothers me. It is particularly annoying when listening quiet music (OST, classical...)

Does Cyanogen Fix Camera Audio issue?

In the stock rom for Nexus One, there is a very poor audio recording rate set to "recording video"... it sounds like you're recording a telephone conversation
8khz?
Does the Cyanogen mod resolve this issue? and if it does..I will gladly root my phone for it
I am working on it, i have the aac encoder source with me, have to make it compatible with N1 shouldnt be a very difficult task. It will make the sampling rate minimum 16khz. I am also working on h264, with Evo dump i think i will be able to do some stuff for it.Rooting your phone for jsut audio is stupidity. Rooting does way more than audio, its a whole new world
it's not just for audio
but the audio is seemingly important (I love taking videos)

SipAgent Play and Record Buffer - milliseconds?

Apparently, the maximum amount of desired latency for voip is about 100 milliseconds.
With SipAgent, the settings for Play and Record buffer are:
-1
640
960. . . and so on; the settings go above 6000.
This can't be in milliseconds, can it?
Record buffer allots time encoding and packetizing, which increases the quality heard by the callee?
Play buffer allots time for decoding the callee, which affects quality heard by the caller?
So, if I want the people I call to hear the highest possible quality, I increase the record buffer, while keeping the play buffer at -1 to reduce overall latency?
During one call, someone said I sounded like I was under water, and many times people say "hello? hello?" during the call while I'm talking, even when the buffers are set to -1.
Also, call quality has been said to be better on froyo, but the developer thinks there is a problem with sipagent using too much battery on froyo.
this should be in the app forum.

Mic recording distortion, due to hardware auto gain

One picture is worth a thousand words
Recorded with Tapemachine. Same conditions, same audio source, same settings... The only difference is hardware autogain control enabled on first sample, and disabled on the second one
How to disable it during video recording? No idea yet
that's a good improvement,maybe supercurio knows how to do it.that would be awesome for a good video recordings.
At least we now know the problem. Very good work.
Hmm i am really waithing for this fix. recording is HD is quite cool and good quality but its useless because the sound always go's bad because its recorded to loud.
New info:
AudioHardwareInterface: AudioHardwareBase::setParamenters(downgain=0)
That's how Tapemachine switch off hardware auto-gain
And auto-gain off seems only to work with mic set to front (AudioSource: VOICE_RECOGNITION)
Thanks to aLogcat app
rafalense said:
New info:
AudioHardwareInterface: AudioHardwareBase::setParamenters(downgain=0)
That's how Tapemachine switch off hardware auto-gain
And auto-gain off seems only to work with mic set to front (AudioSource: VOICE_RECOGNITION)
Thanks to aLogcat app
Click to expand...
Click to collapse
hohoho. Now we just need someone with the knowledge to do that. Thanks rafalense for find out this
Don't forget that it needs those settings to be optimised for audio calls. Most likely, with theses settings, while in call, the audio will catch more of the surrounding than the vocal itself.`
So the best way for this to works would be to make an apps that does the command then goes dormant. Then you can record whatever and, when done, disable and close the dormant app (kinda like TrackerBooster)
BTW, don't forget that you're recording with a crappy built in microphone from a smartphone. I'll try to do the same with an external microphone to see.
I own both the Galaxy S and the Samsung Wave s8500.... And, i gotta say, that the Wave has MUCH better sound when recording video at 720p + Its much better synced with the actual video... Maybe you could look at the Wave and how i manages sound? It has the Bada OS (unfortunately)
Hi !
That's something I'll fix soon using hardware auto-gain.
For now I'm working on a jitter issue and the gain is the next one in the TODO list
As the jitter one is quite difficult I cannot give ETA yet
supercurio said:
Hi !
That's something I'll fix soon using hardware auto-gain.
For now I'm working on a jitter issue and the gain is the next one in the TODO list
As the jitter one is quite difficult I cannot give ETA yet
Click to expand...
Click to collapse
Thanks a lot, supercurio, without you, our galaxy wouldn't be as good as it is.
any updates on this item yet? this would make recording video's so much better.
Try this kernel, mic gain issue seems to be solved, plus other sound improvements:
http://forum.xda-developers.com/showthread.php?t=822756
Also, follow Supercurio. Headphone & FM Radio improvements already done, currently busy with mic:
http://forum.xda-developers.com/showthread.php?t=806195
I'm busy moddifying stock camera, in order to increase samplerate and bitrate. Updates to come
Great efforts by the members of xda, REALLY.
The idiots at Sam**** should have sorted this out though.
rafalense said:
Try this kernel, mic gain issue seems to be solved, plus other sound improvements:
http://forum.xda-developers.com/showthread.php?t=822756
Also, follow Supercurio. Headphone & FM Radio improvements already done, currently busy with mic:
http://forum.xda-developers.com/showthread.php?t=806195
I'm busy moddifying stock camera, in order to increase samplerate and bitrate. Updates to come
Click to expand...
Click to collapse
video bitrate is already quite high but higher audio bitrate might be a good improvement
Hardware is able to record @48000 and around 256Kbps, but video and audio are out-of-sync
My guess, something coded wrong in the driver, so lets see if voodoo sound new kernel fixes it, and then we will record hd video with hd audio as well
A did a test for you minutes ago, check audio info:
rafalense said:
Try this kernel, mic gain issue seems to be solved, plus other sound improvements:
http://forum.xda-developers.com/showthread.php?t=822756
Also, follow Supercurio. Headphone & FM Radio improvements already done, currently busy with mic:
http://forum.xda-developers.com/showthread.php?t=806195
I'm busy moddifying stock camera, in order to increase samplerate and bitrate. Updates to come
Click to expand...
Click to collapse
why do you think this fixes it.. from my readings that kernel does not muck with video recording rates or microphone gain...
Hardcores K12L?
Check yourself. I did, and mic distortion is reduced considerably
rafalense said:
Hardware is able to record @48000 and around 256Kbps, but video and audio are out-of-sync
My guess, something coded wrong in the driver, so lets see if voodoo sound new kernel fixes it, and then we will record hd video with hd audio as well
A did a test for you minutes ago, check audio info:
Click to expand...
Click to collapse
I would recommend trying 44100Hz.
supercurio said:
I would recommend trying 44100Hz.
Click to expand...
Click to collapse
Also possible:
16000 - 22050 - 24000 - 32000 - 44100 - 48000 tested
How can you get the camera app to record at 44.1KHz?
Edit: Got it. Weird though, even though it's 44.1KHz, the cutoff frequency is 12.0KHz instead of 22.050KHz. Not much improvement over 8KHz cutoff, but better than nothing.

Categories

Resources