Detect an audio signal on Aux1

Discussion about writing software for VS1005 and the VSOS Operating System. Also posts about VS1005-related hardware design and device drivers should be posted here.
Post Reply
max_1536
Senior User
Posts: 84
Joined: Thu 2015-02-12 20:16
Contact:

Detect an audio signal on Aux1

Post by max_1536 »

Hi,

We are working on an evolution of an existing product that uses a vs1005.
The product would only receive an audio signal from an auxiliary input and output it as an I2S signal.

But when there is no music playing we would like to turn off the amplifier.
Is it possible to detect when there is and there is not an audio signal from the an auxiliary input?

Thanks,
Max
Hannu
VLSI Staff
Posts: 561
Joined: Mon 2016-05-30 11:54
Location: Finland
Contact:

Re: Detect an audio signal on Aux1

Post by Hannu »

I think something like this in config.txt would do the trick

Code: Select all

#UART driver
uartin
#setclock in startup is needed
run setclock 60 
#ADC driver to stdaudioin
auiadc s
# Input selection and 48 kHz 32b
run auinput line2_1 line2_2 -r48000 -b32
#DC block
ftidcbl
#I2S output to stdaudioout
auoi2sm s
# Output to 48 kHz and 32b
run auoutput -r48000 -b32
#copy stdaudioin to stdaudiout
auxplay
#Let's have a control.
s:shell.ap3
Now the silence detector.

Code: Select all

static u_int32 lastOver = 0;
u_int32 now = ReadTimeCount();
for(i = 0; i < samples; i++) {
  if (limit < abs(*s)) {
    lastOver = now;
    break;
  }
  s++;
}
if ((now - lastOver) > muteTime) {
  GpioSetPin(MUTE_PIN, 1);
} else {
  GpioSetPin(MUTE_PIN,, 1);
}

Something like that. I omitted the bitdepth, and pointer setting stuff. That would go to Write() method of the FTOMUTE. A good starting point to develop this kind of filter is FTOMONO. It is simple on concept level, has all the features and so on.

Now comes the tricky parts.

1) How do you determine limit? External noise determines the noise level.
2) How long is sleep delay? Too short and it sleeps all the time. too long at it sleeps only at night
3) Unmuting. This idea will send on normal volume or shutdown the amplifier. and it maybe not be the nicest feature.
Coming out of mute should be done IMHO waiting the amp to come up, and then ramp volume to old setting

That would require the volume control ioctl() IOCTL_SET_AUDIO_VOLUME should store the current setting and when entering to mute state set volume to 511. And when waking up the amp, ramp the volume back decrementing it to old value. For example in cyclic function.

Have a look on the documentation. I probably skipped many details
https://www.vlsi.fi/fileadmin/software/ ... _Audio.pdf
https://www.vlsi.fi/fileadmin/software/ ... _Shell.pdf

And the documentation and source files in VSOS roots and sources package
viewtopic.php?p=15664#p15664

Some solutions are easier to follow than others.
max_1536
Senior User
Posts: 84
Joined: Thu 2015-02-12 20:16
Contact:

Re: Detect an audio signal on Aux1

Post by max_1536 »

Thanks Hannu for your detailed answer.
Post Reply