Subversion Repositories svnkaklik

Rev

Rev 262 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 262 Rev 348
Line 26... Line 26...
26
 
26
 
27
///////////////////////////////////////////////////////////////////////////////
27
///////////////////////////////////////////////////////////////////////////////
28
//  Tuneable Settings                                                        //
28
//  Tuneable Settings                                                        //
29
///////////////////////////////////////////////////////////////////////////////
29
///////////////////////////////////////////////////////////////////////////////
30
 
30
 
31
#define VERSION "0.93"
31
#define VERSION "0.94"
32
 
32
 
33
//
33
//
34
//  Number of soundcard bytes to read at a time.
34
//  Number of soundcard bytes to read at a time.
35
#define NREAD 2048
35
#define NREAD 2048
36
 
36
 
Line 77... Line 77...
77
int bailout_flag = 0;                           // To prevent bailout() looping
77
int bailout_flag = 0;                           // To prevent bailout() looping
78
int grab_cnt = 0;                       // Count of samples into the FFT buffer
78
int grab_cnt = 0;                       // Count of samples into the FFT buffer
79
 
79
 
80
// Mixer gain settings requested by config file.
80
// Mixer gain settings requested by config file.
81
int req_lgain = -1;              // Line gain
81
int req_lgain = -1;              // Line gain
-
 
82
int req_mgain = -1;              // Microphone gain
82
int req_igain = -1;              // Input gain 
83
int req_igain = -1;              // Input gain 
83
int req_rgain = -1;              // Record level
84
int req_rgain = -1;              // Record level
84
 
85
 
-
 
86
 
-
 
87
// Actual mixer values, read by open_mixer()
-
 
88
int mixer_recmask;      // Recording device mask
-
 
89
int mixer_stereo;       // Stereo device mask
-
 
90
int mixer_line;         // Line input gain setting
-
 
91
int mixer_microphone;	// Microphone input gain
-
 
92
int mixer_igain;        // Overall input gain setting
-
 
93
int mixer_reclev;       // Recording level setting
-
 
94
int mixer_recsrc;       // Mask indicating which inputs are set to record
-
 
95
 
85
//
96
//
86
// Various filenames, contents set by config file.
97
// Various filenames, contents set by config file.
87
//
98
//
88
char logfile[100] = "";
99
char logfile[100] = "";
89
char device[100] = "/dev/dsp";
100
char device[100] = "/dev/dsp";
Line 660... Line 671...
660
      {
671
      {
661
         int left = atoi( fields[2]);
672
         int left = atoi( fields[2]);
662
         int right = atoi( fields[3]);
673
         int right = atoi( fields[3]);
663
         int gain = (right << 8) | left;
674
         int gain = (right << 8) | left;
664
 
675
 
665
         if( !strcasecmp( fields[1], "line")) req_lgain = gain;
676
         if( !strcasecmp( fields[1], "line"))
-
 
677
         {
-
 
678
           req_lgain = gain;
-
 
679
           mixer_recsrc = SOUND_MASK_LINE;
-
 
680
         }
-
 
681
         else
-
 
682
         if( !strcasecmp( fields[1], "mic"))
-
 
683
         { 
-
 
684
           req_mgain = gain;
-
 
685
           mixer_recsrc = SOUND_MASK_MIC;
-
 
686
         }
666
         else
687
         else
667
         if( !strcasecmp( fields[1], "overall")) req_igain = gain;
688
         if( !strcasecmp( fields[1], "overall")) req_igain = gain;
668
         else
689
         else
669
         if( !strcasecmp( fields[1], "record")) req_rgain = gain;
690
         if( !strcasecmp( fields[1], "record")) req_rgain = gain;
670
         else
691
         else
Line 693... Line 714...
693
 
714
 
694
///////////////////////////////////////////////////////////////////////////////
715
///////////////////////////////////////////////////////////////////////////////
695
//  Mixer Stuff                                                              //
716
//  Mixer Stuff                                                              //
696
///////////////////////////////////////////////////////////////////////////////
717
///////////////////////////////////////////////////////////////////////////////
697
 
718
 
698
// Actual mixer values, read by open_mixer()
-
 
699
int mixer_recmask;      // Recording device mask
-
 
700
int mixer_stereo;       // Stereo device mask
-
 
701
int mixer_line;         // Line input gain setting
-
 
702
int mixer_igain;        // Overall input gain setting
-
 
703
int mixer_reclev;       // Recording level setting
-
 
704
int mixer_recsrc;       // Mask indicating which inputs are set to record
-
 
705
 
-
 
706
void open_mixer( void)
719
void open_mixer( void)
707
{
720
{
708
   if( (fdm = open( mixer, O_RDWR)) < 0)
721
   if( (fdm = open( mixer, O_RDWR)) < 0)
709
      bailout( "cannot open [%s]: %s", mixer, strerror( errno));
722
      bailout( "cannot open [%s]: %s", mixer, strerror( errno));
710
 
723
 
Line 780... Line 793...
780
 
793
 
781
      report( 1, "line input gains set to: left=%d right=%d", 
794
      report( 1, "line input gains set to: left=%d right=%d", 
782
             mixer_line & 0xff, (mixer_line >> 8) & 0xff);
795
             mixer_line & 0xff, (mixer_line >> 8) & 0xff);
783
   }
796
   }
784
 
797
 
-
 
798
   if( req_mgain >= 0)
-
 
799
   {
-
 
800
      report( 1, "requesting microphone input gains left=%d right=%d",
-
 
801
             req_mgain & 0xff, (req_mgain >> 8) & 0xff);
-
 
802
 
-
 
803
      if( ioctl( fdm, SOUND_MIXER_WRITE_MIC, &req_mgain) < 0 ||
-
 
804
          ioctl( fdm, SOUND_MIXER_READ_MIC, &mixer_microphone) < 0)
-
 
805
         bailout( "error setting mixer microphone gain");
-
 
806
 
-
 
807
      report( 1, "Microphone input gains set to: left=%d right=%d", 
-
 
808
             mixer_microphone & 0xff, (mixer_microphone >> 8) & 0xff);
-
 
809
   }
-
 
810
 
785
   if( req_igain >= 0 &&
811
   if( req_igain >= 0 &&
786
       (mixer_recmask & SOUND_MASK_IGAIN))
812
       (mixer_recmask & SOUND_MASK_IGAIN))
787
   {
813
   {
788
      report( 1, "requesting overall input gains left=%d right=%d",
814
      report( 1, "requesting overall input gains left=%d right=%d",
789
             req_igain & 0xff, (req_igain >> 8) & 0xff);
815
             req_igain & 0xff, (req_igain >> 8) & 0xff);
Line 808... Line 834...
808
 
834
 
809
      report( 1, "mixer record levels set to: left=%d right=%d", 
835
      report( 1, "mixer record levels set to: left=%d right=%d", 
810
                 mixer_reclev & 0xff, (mixer_reclev >> 8) & 0xff);
836
                 mixer_reclev & 0xff, (mixer_reclev >> 8) & 0xff);
811
   }
837
   }
812
 
838
 
813
   mixer_recsrc = SOUND_MASK_LINE;
839
//mixer_recsrc= SOUND_MASK_LINE;
-
 
840
mixer_recsrc= SOUND_MASK_MIC;
-
 
841
 
-
 
842
   switch (mixer_recsrc)
-
 
843
   {
-
 
844
     case SOUND_MASK_MIC:
-
 
845
     
-
 
846
       if( ioctl( fdm, SOUND_MIXER_WRITE_RECSRC, &mixer_recsrc) < 0)
-
 
847
        bailout( "cannot set mixer recsrc to microphone");
-
 
848
       else report(1, "Input device set to microphone");
-
 
849
     break;
-
 
850
 
-
 
851
     case SOUND_MASK_LINE:
814
   if( ioctl( fdm, SOUND_MIXER_WRITE_RECSRC, &mixer_recsrc) < 0)
852
       if( ioctl( fdm, SOUND_MIXER_WRITE_RECSRC, &mixer_recsrc) < 0)
815
      bailout( "cannot set mixer recsrc to line");
853
        bailout( "cannot set mixer recsrc to line");
-
 
854
       else report(1, "Input device set to line");
-
 
855
     break;
-
 
856
   }
816
}
857
}
817
 
858
 
818
///////////////////////////////////////////////////////////////////////////////
859
///////////////////////////////////////////////////////////////////////////////
819
//  Main                                                                     //
860
//  Main                                                                     //
820
///////////////////////////////////////////////////////////////////////////////
861
///////////////////////////////////////////////////////////////////////////////