looking at https://bitbucket.org/hudson/magic-lantern/src/tip/audio.c
which I assume is what everyone else is referring to?
In my (somewhat limited) embedded programming experience;
If you wish to turn bits on you use a bitwise OR with the bits you want
set to 1, and all other bits set to 0.
If you wish to turn bits off then you need to use a bitwise AND with 0's
for bits you wish to clear, and 1 for all other bits.
For example, when setting the external input.
audio_ic_write( AUDIO_IC_PM3 | 0x07 ); // external input
According to my understanding this will set bit2-0 to '1', and not
affect the state of the other bits in the register. That's okay.
But when you try to enable the internal microphone input
audio_ic_write( AUDIO_IC_PM3 | 0x00 ); // internal mic
This to my understanding will have no effect on the register. If it
happens to already hold the value 0x00 then fine, but it will not
explicitly set the values to '0'. Whatever value is already in the
register will remain there.
If you wish to set b2-0 of AUDIO_IC_PM3 to '0' then you should AND the
value with '1's in the other positions.
audio_ic_write( AUDIO_IC_PM3 & 0xF8 ); //AND with b11111000 (0xF8) to
turn b2-0 off.
I would typically always use AND followed by OR in any register
manipulations, even if you are not planning to clear any bits at the
time you write the code, it allows easier modification later if both
statements are present. The AND can be a general mask for the bits
you're interested in, and the OR can be the bits you wish to set (even
if it's all the same bits you cleared with the AND statement).
So the code might look something like this...
audio_ic_write( AUDIO_IC_PM3 & 0xF8 ); // clear b2-0, set below where
required
if( mic_in )
audio_ic_write( AUDIO_IC_PM3 | 0x00 ); // internal mic
else
audio_ic_write( AUDIO_IC_PM3 | 0x07 ); // external input
Again I apologise if I have missed something here.
Regards, Morgan.
You may want to add one more option to audio.input_source for external
balanced only, I guess some people may not wish to record the internal
mic for whatever reason.
It will be interesting to see how the noise compares on the balanced input.
With respect to analogue and digital gain...
If you have an external microphone amplifier (or mixer). You may get
lower noise by having the mgain turned down on the camera (assuming the
external amplifier is quieter than the internal one).
In general you will want each stage to be turned up as high as possible,
without over driving the next stage.
So in accordance with your comments; if mgain is your first analogue
amplifier stage, then turn it up as much as possible without over
driving the ADC. But don't turn it up all the way if you have to turn
your mic down externally to stop it peaking out.
As for digital gain. I can't see any reason to use digital gain on the
camera (or any digital filters for that matter), since there is nothing
they can do which cannot be done on a computer. Any distortion
introduced on camera cannot be removed later (whereas some computer
software allows non-destructive editing so you can add and remove gain
or filters at will).
Morgan.