Post Reply

[WIP] USB Host support (working)

OP verygreen

27th April 2012, 02:06 AM   |  #211  
Renate NST's Avatar
Recognized Contributor / Recognized Developer
Boston
Thanks Meter: 810
 
1,995 posts
Join Date:Joined: Feb 2012
There is the ALSA layer to audio and on top of that the Android layer.

If you run the alsa_amixer it will tell you a bunch of things.

Code:
alsa_amixer contents
The settings in asound.conf get applied when the corresponding alias is opened.

On my USB adapter there is the playback path, the record path and the record monitor path.
Each of them has a switch to turn on and a volume.
You can play with these values in alsa_amixer.

Right now, I only have Noogie and a Windows machine.
I can't mount the other partitions or access the files.
If I were to get in the habit of bricking my Nook I'd look for a better solution.

On my Nook right now you still just have the selections of 8K or 16K,
however, it records in stereo (from a mono source) at 44100 using either setting.

Such behavior cause data overruns in Skype.

@zholy, I have no idea why your USB buttons are not working, look at dmesg and logcat.
28th April 2012, 03:48 AM   |  #212  
Renate NST's Avatar
Recognized Contributor / Recognized Developer
Boston
Thanks Meter: 810
 
1,995 posts
Join Date:Joined: Feb 2012
Here is a /system/etc/asound.conf which seems to adjust the right things.
The names of controls is for my USB adapter which looks similar to the photo above.
Your control names may be something else.
Run alsa_amixer contents and look at the output.

Code:
defaults.ctl.card 1
defaults.pcm.card 1
defaults.timer.card 1

ctl.AndroidOut
{
   type hw
   card 1
}

ctl.AndroidIn
{
   type hw
   card 1
}

pcm.AndroidPlayback
{
   type hooks
   slave.pcm
   {
      type hw
      card 1
      device 0
   }
   hooks.0
   {
      type ctl_elems
      hook_args
      [
         { name 'Speaker Playback Switch' value on }
         { name 'Speaker Playback Volume' value [150 150] }
      ]
   }
}

pcm.AndroidPlayback_Speaker
{
   type hooks
   slave.pcm
   {
      type hw
      card 1
      device 0
   }
   hooks.0
   {
      type ctl_elems
      hook_args
      [
         { name 'Speaker Playback Switch' value on }
         { name 'Speaker Playback Volume' value [150 150] }
      ]
   }
}

pcm.AndroidPlayback_Speaker_normal
{
   type hooks
   slave.pcm
   {
      type hw
      card 1
      device 0
   }
   hooks.0
   {
      type ctl_elems
      hook_args
      [
         { name 'Speaker Playback Switch' value on }
         { name 'Speaker Playback Volume' value [150 150] }
      ]
   }
}

pcm.AndroidCapture
{
   type hooks
   slave.pcm
   {
      type hw
      card 1
      device 0
   }
   hooks.0
   {
      type ctl_elems
      hook_args
      [
         { name 'Mic Capture Switch' value on }
         { name 'Mic Capture Volume' value 12 }
         { name 'Mic Playback Switch' value on }
         { name 'Mic Playback Volume' value 20 }
      ]
   }
}
Also, I changed the defaults in alsa.default.so to 44.1 record.
That seemed to stop the Nook from always resetting it to 8000.
Binary fix: Offset 2270: 40 1f 00 00 => 44 ac 00 00

I could always get decent recording through Alsa,
but now I can get good 16000 recordings through AudioRecord.
I need to beat on it to accept other rates besides 8000 & 16000.

Skype is still getting buffer overruns and the mute switch does not work.
Still, it looks like it manages to record a fraction of a second correctly.


asound.conf above has been edited 2002-05-02, ctl's don't take device #
Last edited by Renate NST; 2nd May 2012 at 11:50 PM.
The Following User Says Thank You to Renate NST For This Useful Post: [ View ]
29th April 2012, 12:41 AM   |  #213  
Renate NST's Avatar
Recognized Contributor / Recognized Developer
Boston
Thanks Meter: 810
 
1,995 posts
Join Date:Joined: Feb 2012
So I was chatting with this Chinese lady.
She was very patient even though I kept calling her and my Chinese is poor at best.
Of course she is the nice lady on the Skype loopback test.
(The Chinese one seems to work more reliably than the English one.)

What I mean to say is that Skype works fine.

The problem is that the Nook reports a ridiculously small minimum buffer size for audio.
If you hack /system/framework.jar it will use a realistically sized buffer.
The enclosed text file replaces the corresponding method in the smali for AudioRecord.

Code:
adb pull /system/framework/framework.jar
apktool d framework.jar Framework
Then you edit in the replacement in smali/android/media/AudioRecord.smali
Code:
apktool b Framework framework.jar
adb push framework.jar /system/framework/
Note: Changing this will make my tool AudioCtl say that it supports every sampling rate.
This is not true, it remains at just 8000 & 16000 mono.
I'm still working on beating on the init to do quality recording at 44.1
Attached Files
File Type: txt parte.txt - [Click for QR Code] (580 Bytes, 36 views)
Last edited by Renate NST; 29th April 2012 at 01:09 AM.
The Following User Says Thank You to Renate NST For This Useful Post: [ View ]
2nd May 2012, 01:50 PM   |  #214  
Renate NST's Avatar
Recognized Contributor / Recognized Developer
Boston
Thanks Meter: 810
 
1,995 posts
Join Date:Joined: Feb 2012
Yet more mods, sigh.

This one prevents rotating of your arrow keys when in landscape mode.
Any arrow keys are on an external keyboard which doesn't rotate.

Code:
adb pull /system/framework/services.jar
apktool d services.jar Services
Then you edit in the replacement in smali/com/android/server/KeyInputQueue.smali
Code:

Code:
apktool b Services services.jar
adb push services.jar /system/services/
Attached Files
File Type: txt partf.txt - [Click for QR Code] (440 Bytes, 47 views)
Last edited by Renate NST; 2nd May 2012 at 09:45 PM.
The Following 3 Users Say Thank You to Renate NST For This Useful Post: [ View ]
3rd May 2012, 12:12 PM   |  #215  
Renate NST's Avatar
Recognized Contributor / Recognized Developer
Boston
Thanks Meter: 810
 
1,995 posts
Join Date:Joined: Feb 2012
Here is a new UsbMode, version 1.5, with a fix and a bit of cosmetics.
There was a bug in a previous version that left some disconnected shells.
Last edited by Renate NST; 29th June 2012 at 07:06 PM.
The Following 3 Users Say Thank You to Renate NST For This Useful Post: [ View ]
9th May 2012, 06:45 PM   |  #216  
Renate NST's Avatar
Recognized Contributor / Recognized Developer
Boston
Thanks Meter: 810
 
1,995 posts
Join Date:Joined: Feb 2012
Ok, just a bit of a heads up and a bump.
I've beaten on the code and I've got high quality recording at 44.1 to work.
The fix is binary editing libaudio.so to allow more rates/formats.
I'm working on making something cleaner, but it is proof of concept.

Eventually I'd like to get Lame MP3 encoder working with it,
but for now big micro SD cards are cheap enough.

If you're really desperate to try this out, use a 1.1.2 libaudio.so
Code:
[00009188] B1 F5 FA 54 => 70 BD 00 BF
[000091EC] 6C 33 => 00 05
Note: libaudio.so is the Android layer interface to ALSA.
If you are using the audio recorder application further down,
it uses ALSA directly and bypasses this file.
Last edited by Renate NST; 24th June 2012 at 01:15 PM. Reason: Added note:
The Following User Says Thank You to Renate NST For This Useful Post: [ View ]
10th May 2012, 06:55 AM   |  #217  
Senior Member
Thanks Meter: 19
 
147 posts
Join Date:Joined: Jan 2012
i am now trying to install adb on linux (i am new immigrant to the ubuntu) in a time i hope i'll finaly test you mods. especially skype and casablanca on NST :]
14th May 2012, 07:11 PM   |  #218  
Renate NST's Avatar
Recognized Contributor / Recognized Developer
Boston
Thanks Meter: 810
 
1,995 posts
Join Date:Joined: Feb 2012
As usual, a heads-up, a bit of a bump and seeing whether there is interest.

Android does not support 24 bit recording.
Yes, you can hack stuff to configure the ALSA to work correctly,
but the Android buffer handling didn't plan for 24 bits and munches the alignment.

I've got an application now that will do 24 bit recording without using the Android audio.
I haven't actually gotten it to the point where you can play it back (on the Nook).
However, with a Lexicon Alpha interface and a Shure SM58 it makes a handy field recorder.

No, I'm not an audio purist, but it's very handy to record with lots of bits in case you have to raise the gain when mixing it later.
For final recordings, 16 bit is fine with me.
The Following User Says Thank You to Renate NST For This Useful Post: [ View ]
15th May 2012, 07:22 PM   |  #219  
Senior Member
Thanks Meter: 19
 
147 posts
Join Date:Joined: Jan 2012
pack
Cloud you please make automated pack or tutorial how to incorporate all the mods you've developed?
15th May 2012, 07:39 PM   |  #220  
Renate NST's Avatar
Recognized Contributor / Recognized Developer
Boston
Thanks Meter: 810
 
1,995 posts
Join Date:Joined: Feb 2012
Quote:
Originally Posted by mrWax

Cloud you please make automated pack or tutorial how to incorporate all the mods you've developed?

Mmm, you do have a valid point.
These audio mods are getting a bit out of hand.
You need a score card just to keep track of them.

I'm trying to find some cleaner ways to do some of these mods.
Right now, this is for intrepid folks that want to dive back into the thread.
I'm working on custom permissions for audio hardware access.
I will be doing a recap shortly.

Still, I'd like to get some feedback on what people want this for.
  • MP3 playing
  • Internet radio
  • Skype
  • Home recording
  • Memo taking
  • Speech to text

Post Reply Subscribe to Thread

Tags
usb host, usbhost
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Top Threads in Nook Touch Android Development by ThreadRank