Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#173769 - 04/08/2003 20:02 Mic Check
753
member

Registered: 25/10/1999
Posts: 149
I am trying to access a microphone on the empeg. Naive as I am, I first tried it the way I would do it on my linux box. I checked SOUND_MIXER_READ_DEVMASK, which returns a bitmask which in turn tells the devices supported by the particular mixer.

if (ioctl(fd, SOUND_MIXER_READ_DEVMASK, &mask_mixer) == -1)
{
return(MIXER_ERR);
}

if (!(mask_mixer & SOUND_MASK_MIC))
{
fprintf(stderr, "No mic.\n");
return(MIXER_ERR);
}

No luck. Checking the source I found this comment in empeg.h:
/* Sound IOCTLs */
/* Make use of the bitmasks in soundcard.h, we only support.
* PCM, RADIO and LINE. */

So how can I check for a mic and more imporantly set it as the active recording channel?
Do I use the EMPEG_AUDIOIN_*? And if, is there example code somewhere maybe?
_________________________
_______ Thomas

Top
#173770 - 04/08/2003 20:50 Re: Mic Check [Re: 753]
tman
carpal tunnel

Registered: 24/12/2001
Posts: 5528
You using the right device? The mic is connected to a seperate chip and also has a seperate device file. It's /dev/audioin

Top
#173771 - 04/08/2003 22:20 Re: Mic Check [Re: 753]
genixia
Carpal Tunnel

Registered: 08/02/2002
Posts: 3411
As tman mentioned, you're looking at the wrong device. Check out empeg_cs4231a.[c|h]

The empeg uses the SAA77h05 DSP for it's output. The DSP unfortunately doesn't allow for analogue input signals to be passed as a digital representation to the CPU. So although the Line In and Radio inputs are digitised, manipulated, and mixed by the DSP, there is no way (for example) to be able to do visuals on those inputs. So the empeg has a second audio chip the CS4231a in order to do that. When you switch to the Tuner or the Aux In, the CS chip ADCs sample the inputs so that visuals can be used.
Note that this doesn't happen for MP3 playback ('PCM' mode in the DSP). We already have the digital representation needed for the visuals.
What isn't clear to me (I haven't really looked) is how to ensure that the microphone input is played. The CS4231a has a limited sampling rate of 22.05KHz. The DSP is locked down to 44.1KHz. That means that you cannot directly sample the microphone to memory and then play it as is. You would have to upsample it to 44.1KHz first. This can be done the dirty way by doubling every sample. Then you'd need to play the sample using the DSP in 'PCM' mode, ie in MP3 mode.
This could make full duplex rather difficult - you would be relying on the CPU to maintain real-time processing of the samples.
_________________________
Mk2a 60GB Blue. Serial 030102962 sig.mp3: File Format not Valid.

Top
#173772 - 05/08/2003 15:05 Re: Mic Check [Re: genixia]
753
member

Registered: 25/10/1999
Posts: 149
As tman mentioned, you're looking at the wrong device.

Thanks, to both of you, that pushed me in the right direction. I have the recording channel set to the microphone input now.

What isn't clear to me (I haven't really looked) is how to ensure that the microphone input is played.

I don't want to play back the recorded mic input.

The CS4231a has a limited sampling rate of 22.05KHz.

Hmm, actually I'd like to record at 16KHz. I've tried setting the samplerate using EMPEG_AUDIOIN_WRITE_SAMPLERATE as definded in empeg.h. It works when I set it to 22050, which it is already set to anyway, but fails for 16000. Is the CS4231a's samplerate locked as well?
_________________________
_______ Thomas

Top
#173773 - 05/08/2003 15:10 Re: Mic Check [Re: 753]
tman
carpal tunnel

Registered: 24/12/2001
Posts: 5528
I don't think it supports 16KHz. Not read the driver fully but a quick grep through gives a list of supported sample rates. They're 11.025KHz, 22.05KHz and 29.4KHz. No idea what will happen if you select one of the other two sample rates though.

Top