USB Audio Input??? - page 2 - Feature Requests - CHDK Forum

USB Audio Input???

  • 46 Replies
  • 26702 Views
Re: USB Audio Input???
« Reply #10 on: 06 / April / 2008, 14:25:29 »
Advertisements
jetzt,

Thanks for the "input." Unfortunately the TX-1, unlike other larger cameras really has no space available to even install a micro-jack and, even if you could, you would be relying on an unbalanced, high-impedance audio input which provides no shielding, and is therefore subject to hum and other rfi.

No, I really believe that a software hack using the USB port is doable and will provide the best quality audio in the most reliable way. Besides, if I hardware hack my camera, how can anyone else take advantage of it? A CHDK software hack will potentially open this up to everyone with a camera!

 
~~~~~~~~~~~~~~~~~~~~~

<")%%%><<

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: USB Audio Input???
« Reply #11 on: 06 / April / 2008, 17:38:31 »
I have no idea why this feature request is attracting such negative responses from people .

Well, browse around the other feature requests and you'll find that the thing with USB is that we really want to do a whole lot of things with it but either can't or don't know how.

Currently the best we can do with USB is to detect whether USB cable is connected or not, with a resolution of something like ten or twenty milliseconds. We can use it as a remote trigger or to communicate with the camera extremely slowly. For stereo photography, two cameras can be synchronized by this USB cable detect.

Some cameras are also remote controllable in webcam style and also remote wakeable via USB, but these are original Canon features and only available for some models.

So we are pretty far from being able to receive an audio stream via USB. We'd be thrilled to be able to receive 300 bytes per second of control data first...

*

databoy

Re: USB Audio Input???
« Reply #12 on: 06 / April / 2008, 23:24:30 »
Cybercom,

You may be a professional working in a recording studio but the majority of people on forums are beginners who just want to use their equipment. I am a hardware guy not a software guy; I do not believe in re-inventing the wheel.

If you work in a recording studio you would know that Windows does not process the audio in high end  professional audio equipment. It just does the switching and mixing controls to the A to D and D to A amplifiers. Windows XP out of the box does not have the latency to process audio or video properly. XP has to be tweaked extensively and all the networking protocols removed; otherwise you are left with artefacts. 

I live in Perth, Australia. The TV stations still use a double sound system and dub in the studio. Australia is PAL; USA is NTSC.

With all that equipment and knowledge at your disposal you should know that you cannot bypass A to D converters in a piece of equipment without opening the equipment and letting loose with a soldering iron. I may not work in a recording studio; I have some electronics and electrical knowledge; build and modified high end HI-FI equipment and know how to use a soldering iron. The microphone is hard wired to an analogue amplifier then fed into the A to D converter. The audio mute is either done through a mute circuit or an address line on the A to D chip.

Bypassing the on-board A to D altogether and feeding audio down the USB line is worthwhile proposition. You need an external microphone, analogue amplifier, A to D converter and USB converter. If you have that equipment ok you have a good digital source. The problem is that in Windows based computers everything is processed by software. In consumer goods they use a small microprocessor for control purposes and a small OS, all the rest is done in specialised hardware chips, usually one big LSI chip. You would still need access to the hardware information to bypass the A to D hardware on the camera. I cannot see how you would do it in software without a major rewrite of the OS.

I am not going to enter into a flame war with anyone on the forum. If you or anyone else have schematics, technical documents or access to the schematics for any CHDK compliant Canon cameras post them on the forum.     

Re: USB Audio Input???
« Reply #13 on: 07 / April / 2008, 01:32:21 »
I still don't get what recording studios and windows have to do with my feature request of getting USB audio into a camera, but..


Bypassing the on-board A to D altogether and feeding audio down the USB line is worthwhile proposition. You need an external microphone, analogue amplifier, A to D converter and USB converter. If you have that equipment ok you have a good digital source. ...

You would still need access to the hardware information to bypass the A to D hardware on the camera. I cannot see how you would do it in software without a major rewrite of the OS.

  

Let's just address the two points you make here:

A USB  Mixer satisfies all of the criteria you outline for hardware, so a good digital source is immediately available to feed the USB Port.

As to your second point, CHDK is exactly that, a rewrite of the OS...

If I had tight chops in the programming realm, which I don't, and which is why I put in this feature request in the first place, I would think based on my understanding of digital audio that there is a data flow that runs something like this:

Physical sound hits microphone, analog voltages generated by the microphone are sampled at some clock and bit rate by an A/D converter and FED INTO BUFFERS AS DIGITAL WORDS. CPU reads buffers and records them to SD Card.

Buffers have addresses in firmware for I/O, so to replace the onboard mic audio with the external mixer audio:

CHDK reads incoming audio from USB port. Writes it to buffer space on the SD card and tells the CPU not to pay attention to the firmware addresses used by the firmware buffers, but rather to use the addresses on the SD card (maybe it's possible to find space in the firmware to buffer the audio. There must be space avalable somewhere). There has to be a routine in the firmware pointing the CPU to an address for the buffer.

Or, why can't CHDK simply overwrite the buffer with the USB data just before it is read by the CPU?

CPU happily uses the new data pointed to by CHDK and records it to the SD Card as audio just as it normally would.

I also have no desire to engage in this continuing naysaying about why this can't be done because of windows and recording studios and DAW's and whatever. And I'm sure that what I've just written will open up the possibility of even more negativity as to why this or that part of it can't be done because of Linux and micro basic or some other equally unsupportive thing.

Again, let's try to have some positive input on this idea and stop trying to convince me that it can't be done. If you think it's a bad idea, that's fine, but keep your opinion to yourself.

If YOU haven't tried to do it then whatever you say is really irrelevant to the posting of a "feature request" here, so please don't.

~~~~~~~~~~~~~~~~~~~~~

<")%%%><<


*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: USB Audio Input???
« Reply #14 on: 07 / April / 2008, 16:50:32 »
I'm not really an expert on CHDK internals so someone correct me if I'm wrong.

First, CHDK is not a rewrite of the camera's OS. For the sake of safety, the developers have been quite careful not to make modifications to the camera firmware and the original and complete OS is still there running alive and well. CHDK inserts some hooks here and there to get some time to do it's thing periodically. It uses a great deal of functions and variables provided by the OS to do many of its wonderful tasks, while a whole lot of other stuff is completely new and only uses standard C libraries from the OS.

Now, if I'm not mistaken, CHDK gets it's job done every time the camera polls it's keyboard for keypresses, which only happens every 10 ms or so. This is quite a long time in audio recording or for fast USB data transfer. Both the ADC and USB related buffers are probably interrupt driven and if your camera model actually compresses audio during video recording, it probably does it using an external codec or ip block with a buffer possibly shorter than 10 ms.

And even if this would be resolved, this only applies to a subset of camera models as most of them have really crappy audio capabilities (like 8-bit mono at 11 kHz) and their hardware such as A/D converters, audio compression codecs, buffers etc. just can't be expected to scale 16-fold, it would have been incredible waste of money from Canon.

So, if I'm not mistaken, what you're thinking probably requires changing the camera firmware, which is potentially destructive (the developers really don't have a free supply of spare cameras :D) and hard to port to different camera models.


But even finding a readable USB or microphone buffer could make some neat stuff possible...

Re: USB Audio Input???
« Reply #15 on: 07 / April / 2008, 17:26:26 »
fudgey,

I know it won't be easy and your input makes perfect sense, but you also see the potential benefits.

The TX-1 has already got the capability to do 44.1kHz, 16-bit stereo, so the hardware capabilities are built-in for that camera at least.

Hmmm! Interrupt driven you say. Say we have CHDK write the USB audio to a buffer somewhere while it is polling for that interrupt.

Once the CPU sees the interrupt and writes the microphone's audio to the SD Card, we wait the appropriate amount of time and then overwrite it with our USB audio.

Somewhere there must be a register that has the present address of where the data is being written to on the card by the CPU. We simply (!!! I know, I know!) read that address, store it until we're ready and then write to that address on the card from our buffers.

44,100 (Hz) x 16 (bits) x2 (stereo) / 100 (10 msec) = 14,112 bits or 1,764 8-bit words for every 10-ms window.

These cameras can write MJPEG HD video to a 6x card, so I can't imagine that this amount of audio would be a problem.
« Last Edit: 07 / April / 2008, 17:29:21 by cybercom »
~~~~~~~~~~~~~~~~~~~~~

<")%%%><<

Re: USB Audio Input???
« Reply #16 on: 19 / April / 2008, 21:18:38 »
Would that possibly cause the audio to be "off" from the video just a bit?

I'm thinking that just having one tiny mic discretely placed on either side of a baseball cap would be convenient and ideal.
You smite like a girl!

*

Offline jeff666

  • ****
  • 181
  • A720IS
Re: USB Audio Input???
« Reply #17 on: 21 / April / 2008, 09:44:15 »
The TX-1 has already got the capability to do 44.1kHz, 16-bit stereo, so the hardware capabilities are built-in for that camera at least.

Its audio-hardware may by capable of doing that, but that's in no way connected to the usb-port.

You seem to mix up several things:
1. usb-mixers are devices. They need a host (usually the PC-side of the cable) and the host needs to know how to manage the device (usually a driver does that).
2. Your camera is a device, as well. So it's technically not even possible to attach another device to your cam. The usb-controller wouldn't know how to talk to it. This limitation prevents to exchange any information between the devices. Even if you could write a driver, it couldn't transport data to the other end of the cable.
3. usb-mixers exchange data with their host using the usb-protocol. What we do to watch the usb-port doesn't do anything with any protocol. It justs checks if power is available. The original OS uses this information as a hint that it is connected to a host.
4. Even if the usb-is-connected-state could be read fast enough (which I hardly believe) it's only digital. Either power is connected or it is not. To read information from a microphone, you would need an A/D-converter which connects to the microphone on one end and to your cam on the other end. It would also need to send raw-audio using TTL-levels on its output so the usb-is-connected-state is triggered.

Short summary: not doable due to hardware limitations.

Cheers.


Re: USB Audio Input???
« Reply #18 on: 21 / April / 2008, 16:04:43 »
1. That's correct, but forgetting for a minute the hardware side of things, all we are talking about is a data stream using USB protocol:

The USB Protocol

If a software driver can send the proper handshaking and get properly clocked data to flow, then the device at the other end, the mixer, could care less if it's a host or a ghost. We are not trying to satisfy Plug-and-Play recognition of multiple manufacturers, just turn on the data stream and get it into the camera where we can access & direct it.

2. Again forgetting the USB controller hardware (basically there to keep multiple devices playing together nicely and auto-recognizing new devices, etc.) if CHDK software can trigger and write the incoming data stream to the proper address on the SD card, then we have accomplished our goal - taken USB data from the mixer and saved it.

USB is bi-directional, so the host can receive data from the device and can send data to the device. I can upload images and sounds to the camera using the software provided with the camera, so obviously data is at the end of the cable going into the camera. If CHDK can access and process that data, then the camera could care less if it's a device or where it's coming from.

There obviously must be a way to tell the camera's hardware that there will be incoming data since I can upload images to the camera from my computer and write them to the SD card. Why can't CHDK software trick the camera into thinking that the command to allow data to come in and be written to the SD card is coming from a host...?? In which case, the incoming data can be from whatever USB device we choose including a USB Mixer.

3. I'm not talking about the power lines, I'm talking about the data lines. Yes, checking for the presence of power to trigger a remote is one thing, but I'm considering accessing the data on the other two pins. It has been mentioned that those routines have not yet been found, but that doesn't mean developers aren't looking:-)

4. Again, I'm not talking about whether or not there is a connection/power on pins 1 and 4. Full speed USB data lines operate at 12 Mbps which is certainly fast enough for 44.1kHz, 16-bit, stereo.

And once again, because no one here seems to understand how they work and continues to raise the same irrelevant objections:

a USB Mixer takes the audio from one or multiple microphones and uses Analog to Digital (A/D) converters to create a digital bit stream which it outputs using the USB protocol at its USB port.

It does NOT use the power lines of pins 1 & 4 to do this.

It uses the Data Lines on pins 2 & 3.

Testing for "usb-is-connected-state" has absolutely NOTHING TO DO WITH THIS!!!

Let's find the routines that allow the cameras to read the USB Data lines first. Then let's determine whether or not this can be done. In the meantime, will everyone please stop telling me the reasons you THINK it can't be done without really knowing what you are talking about.

A USB Mixer satisfies ALL the requirements needed to provide the audio data in USB Protocol format to the USB jack of the camera. We need to focus on how to handshake with that data stream and once it's incoming, how to write it to the SD card.

Short summary: you seem to mix up several things. No actual hardware limitations have been discussed.
~~~~~~~~~~~~~~~~~~~~~

<")%%%><<

*

Offline jeff666

  • ****
  • 181
  • A720IS
Re: USB Audio Input???
« Reply #19 on: 21 / April / 2008, 17:11:23 »
Short summary: you seem to mix up several things. No actual hardware limitations have been discussed.

All host-vs-device-related discussions I followed suggested that all handshaking and low level data exchange is done by hardware. The few devices that could act as both device and host have a host controller on their chipset (and it is just not enabled, by default). I've seen several SOCs that have a usb host somewhere. I haven't seen a device without a host controller being able to act as host, though.

But I don't want to stop you from investigating. Maybe it is possible to send/receive raw data from the USB port and write a host controller in software. I just don't find it very likely.

Cheers.

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal