Topic: amixer as mixer and volume control for HDSP ?

Hi folks.

I am trying to setup a headless system based on a HDSP 9632. The problem that comes with it is that I do have major problems to set the card mixer - routing and volume without running
"HDSPmixer" which obviously requires X to be up'n running.

I would like to load a default config at system startup and changes during operation by using amixer.

As far as I understood below amixer  control would be my interface:

numid=5,iface=HWDEP,name='Mixer'
; type=INTEGER,access=rw------,values=3,min=0,max=65536,step=1
: values=0,0,0

The question is what values and logic to apply: Afaik the first 0 stands for inputs , the 2nd for output and the 3rd value for gain.  How to do the mapping - that's the question?

How do I read out the status?

HDSPconf though can easily be handled with amixer, this won't be an issue.

THX
\Klaus

2 (edited by soundcheck 2009-10-25 19:37:48)

Re: amixer as mixer and volume control for HDSP ?

Hi folks.

It took me while to figure it out. (Daily life under Linux).

As a matter of fact  "amixer cset numid=5 $input,$output,32768" will set the chosen route to 0db.

The Linux/Alsa documentation around the HDSP cards is unfortunately pretty "fragmented"  and HDSPmixer is not what I'd call a 100% clone of Totalmix, which doesn't make life easier,.

Anyhow. The main problem was to find a working approach with amixer. The main issue was actually to find out the right channel id's of input and output channels.

There are endless possibilities and the ones listed in the script header were not matching the ones I identified.. Therefore I wrote a simple script to check them all out.

Perhaps somebody else can make use of the script - that's why I attach it.

Have fun. Enjoy.
\Klaus


HDSPscan

------------------------------------------------------------------

#!/bin/bash
#
# written by Klaus Schulz 10/25/2009
#
# This script scans the matrix mixer of RME HDSP  9632 for input/output connections
# Your current setting will be removed. Use the script at your own risk.
#
# RME HDSP  9632 ( as per definition)
# inputs: 0-7 (analog), 16-23 (adat), 24-25 (spdif)  26-43 (playback channels)
# output: 0-7 (analog), 16-23 (adat)  24-25 (spdif), 26-27 (line out)

track="/dev/shm/play.wav"  # will be generated by the script!!!!!!!!!
alsainterface="plughw:0,0"

inputs_left=( 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 )
inputs_right=( 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 )
let cnt_i=${#inputs_left[@]}-1

outputs_left=( 0 2 4 6 8 10 12 14 16 18 20 22 24 26 )
outputs_right=( 1 3 5 7 9 11 13 15 17 19 21 23 25 27 )
let cnt_o=${#outputs_left[@]}-1



function generate_track () {
which sox  > /dev/null 2>&1 || { echo "Please install sox first!"; exit 1 ; } ;
sox -r 44100 -b 16 -c 2 -n $track synth 2 sine 300-3300 gain -18  # gain in db
}



function init_matrix () {
    echo -n "Initializing HDSP matrix-mixer..."
    for output in $(seq 0 27); do
        for input in $(seq 0 43); do
            echo -n "."
            amixer -D hw:DSP cset numid=5 $input,$output,0 > /dev/null 2>&1
        done
    done
echo
}


function scaninputs () {
for i in  $(seq 0 $cnt_i) ; do         
          in_l=${inputs_left[$i]}
          in_r=${inputs_right[$i]}
          for y in  $(seq 0 $cnt_o) ; do
                    out_l=${outputs_left[$y]}
                    out_r=${outputs_right[$y]}
                    echo  "Connecting input:$in_l/$in_r to output: $out_l/$out_r"
                    amixer -D hw:DSP cset numid=5 $in_l,$out_l,32768 > /dev/null 2>&1
                    amixer -D hw:DSP cset numid=5 $in_r,$out_r,32768 > /dev/null 2>&1
          done
          aplay  -D$alsainterface -fcd "$track" > /dev/null 2>&1 &
          echo "Playback started..."
          echo -n "Any sound ? (y/(N)):"
          read z
         
          if [ "$z" == "y" ] ; then echo "Identified inputs: $in_l/$in_r" ;  break ; fi 
         
          for y in  $(seq 0 $cnt_o) ; do   
                    out_l=${outputs_left[$y]}
                    out_r=${outputs_right[$y]}
                    echo  "Connecting input:$in_l/$in_r to output: $out_l/$out_r"
                    amixer -D hw:DSP cset numid=5 $in_l,$out_l,0 > /dev/null 2>&1
                    amixer -D hw:DSP cset numid=5 $in_r,$out_r,0 > /dev/null 2>&1
          done       
done
if [ "$z" != "y" ] ; then echo "No working connection identified..." ; exit 1 ; fi
}


function scanoutputs () {
for k in  $(seq 0 $cnt_o) ; do
     out_l=${outputs_left[$k]}
     out_r=${outputs_right[$k]}
     echo  "Connecting input:$in_l/$in_r to output: $out_l/$out_r"
     amixer -D hw:DSP cset numid=5 $in_l,$out_l,32768 > /dev/null 2>&1
     amixer -D hw:DSP cset numid=5 $in_r,$out_r,32768 > /dev/null 2>&1
     aplay  -D$alsainterface -fcd "$track" > /dev/null 2>&1 &
     echo "Playback started..."
     echo -n "Any sound ? (y/(N)):"
     read z
     if [ "$z" == "y" ] ; then echo "Identified outputs: $out_l/$out_r" ;  break ; fi 
     amixer -D hw:DSP cset numid=5 $in_l,$out_l,0 > /dev/null 2>&1
     amixer -D hw:DSP cset numid=5 $in_r,$out_r,0 > /dev/null 2>&1
done
}


echo "Generating test-track..."
generate_track
init_matrix
echo "Scan inputs..."
scaninputs
init_matrix
echo "Scan outputs..."
scanoutputs
echo
echo "Result: inputs: $in_l/$in_r outputs: $out_l/$out_r"



exit 0

------------------------------------------------------------------------------

Re: amixer as mixer and volume control for HDSP ?

Hi,

I just saw your post. Zob posted some good information on this in response to your other question. I just want to add you should keep in mind that the channel assignments may change with different sample rates as the adat channels get wired together with higher sample rates to get the necessary bandwidth.

Cheers
Maarten