extended software mixer patch

2002-06-23 Thread Ed Sweetman

This patch aims at removing dependency on hardware mixers to all other
supported platforms save, irix, solaris, and qnx as there is absolutely
no way i can test them or know anybody who can.  

This patch is nearly entirely untested...i'm looking for some feedback
on how it behaves.  

software controlled mixers are as follows

esound,dsound, soundcard (linux and win32 and beos), arts, and alsa
(even though it's the 0.5x version).   Some tweaks may be needed so any
modulations in volume when playing audio or other errors should be
reported so i can follow up on them and tweak the code there.  


Also, dead code has not been removed completely yet,  still working on
that... so use this patch at your own risk.(not ready to be used in
cvs) 

the june_23.patch patch must be applied prior to this one. 


diff -Naur -x CVS -x corba -x *.log -x *.orig -x *.rej ../clean/freeamp/io/alsa/unix/linux/include/alsapmo.h ./freeamp/io/alsa/unix/linux/include/alsapmo.h
--- ../clean/freeamp/io/alsa/unix/linux/include/alsapmo.h	Sun May  7 17:38:51 2000
+++ ./freeamp/io/alsa/unix/linux/include/alsapmo.h	Sun Jun 23 15:40:14 2002
 -49,6 +49,9 
 #define BIT_SELECT  0x1f
 #define SLEEPTIME   256
 
+int Right=0;
+int Left=0;
+
 static const uint32 OBUFFERSIZE = 2 * 1152;
 
 enum {
diff -Naur -x CVS -x corba -x *.log -x *.orig -x *.rej ../clean/freeamp/io/alsa/unix/linux/src/alsapmo.cpp ./freeamp/io/alsa/unix/linux/src/alsapmo.cpp
--- ../clean/freeamp/io/alsa/unix/linux/src/alsapmo.cpp	Thu Oct 19 13:04:10 2000
+++ ./freeamp/io/alsa/unix/linux/src/alsapmo.cpp	Sun Jun 23 15:40:01 2002
 -182,65 +182,17 
 
 void AlsaPMO::SetVolume(int32 left, int32 right)
 {
-   int   err;
-   snd_mixer_t *pMixer;
-
-   err = snd_mixer_open(pMixer, m_iCard, 0);
-   if (err  0)
-  return;
-
-   if (m_iChannel = 0)
-   {
-  err = snd_mixer_group_read(pMixer, m_group);
-  if (err  0)
- return;
-
-  left = (int)((double)(m_group.max - m_group.min) * 
-   (double)left * 0.01) + m_group.min;
-  right = (int)((double)(m_group.max - m_group.min) * 
-   (double)right * 0.01) + m_group.min;
-  for (int chn = 0; chn = SND_MIXER_CHN_LAST; chn++) {
-  if (!(m_group.channels  (1chn)))
-  continue;
-
-  if (chn == 0)
-  m_group.volume.values[chn] = left;
-  else
-  if (chn == 1)
-  m_group.volume.values[chn] = right;
-  else
-  m_group.volume.values[chn] = (left + right) / 2;
-  }
-  snd_mixer_group_write(pMixer, m_group);
-   }
-   snd_mixer_close(pMixer);
+static int vol_scale[] = {0,1,2,4,7,12,18,26,35,45,56,69,75,87,100 };   
+Right = vol_scale[(int)(14*((double)right/100))];   
+Left = vol_scale[(int)(14*((double)left/100))];
 } 
 
 void AlsaPMO::GetVolume(int32 left, int32 right)
 {
-   int   err;
-   snd_mixer_t *pMixer = NULL;
-
-   err = snd_mixer_open(pMixer, m_iCard, 0);
-   if (err != 0)
-   {
-  return;
-   }
-
-   if (m_iChannel = 0)
-   {
-  err = snd_mixer_group_read(pMixer, m_group);
-  if (err  0)
- return;
-   }
-   else
-  return;
-
-   snd_mixer_close(pMixer);
-   left = (int)(((float)((m_group.volume.values[0] - m_group.min) * 100) /
-(float)(m_group.max - m_group.min)) + 0.5);
-   right = (int)(((float)((m_group.volume.values[1] - m_group.min) * 100) /
-(float)(m_group.max - m_group.min)) + 0.5);
+if(Left == 0  Right == 0){
+left = Left;
+	right = Right;  
+}   
 } 
 
 Error AlsaPMO::Init(OutputInfo* info) 
 -529,6 +481,14 
   // Now write the block to the audio device. If the block doesn't
   // all fit, pause and loop until the entire block has been played.
   // This loop could be written using non-blocking io...
+  short *data = (short *)pBuffer;   
+  if(Right == -1) Right = Left; 
+  for (int i=0; i  m_iDataSize  1; i+=8) {   
+	int v=(int) ((*(data) * Left) / 100);  
+	*(data++)=(v32767) ? 32767 : ((v-32768) ? -32768 : v);   
+	v=(int) ((*(data) * Right) / 100); 
+	*(data++)=(v32767) ? 32767 : ((v-32768) ? -32768 : v);   
+  }
   for(;!m_bExit  !m_bPause;)
   {
   iRet = snd_pcm_write(m_handle,pBuffer,m_iDataSize);
diff -Naur -x CVS -x corba -x *.log -x *.orig -x *.rej ../clean/freeamp/io/arts/include/artspmo.h ./freeamp/io/arts/include/artspmo.h
--- ../clean/freeamp/io/arts/include/artspmo.h	Thu Jan 11 17:34:08 2001
+++ ./freeamp/io/arts/include/artspmo.h	Sun Jun 23 15:24:46 2002
 

Re: extended software mixer patch

2002-06-23 Thread Jason Zubarik

So how far off is the next version of FreeAmp, anyway?


- Original Message - 
From: Ed Sweetman [EMAIL PROTECTED]
To: Robert Kaye [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Sunday, June 23, 2002 4:24 PM
Subject: extended software mixer patch


 This patch aims at removing dependency on hardware mixers to all other
 supported platforms save, irix, solaris, and qnx as there is absolutely
 no way i can test them or know anybody who can.  
 
 This patch is nearly entirely untested...i'm looking for some feedback
 on how it behaves.  
 
 software controlled mixers are as follows
 
 esound,dsound, soundcard (linux and win32 and beos), arts, and alsa
 (even though it's the 0.5x version).   Some tweaks may be needed so any
 modulations in volume when playing audio or other errors should be
 reported so i can follow up on them and tweak the code there.  
 
 
 Also, dead code has not been removed completely yet,  still working on
 that... so use this patch at your own risk.(not ready to be used in
 cvs) 
 
 the june_23.patch patch must be applied prior to this one. 
 


___
[EMAIL PROTECTED]
http://www.freeamp.org/mailman/listinfo/freeamp-dev



Re: extended software mixer patch

2002-06-23 Thread Ed Sweetman

a little while's off it seems.   


I've already fixed some bugs with my extended software mixer patch.  
esd now works correctly 
artsd now works correctly
oss works correctly

alsa is obscolete but i suspect it too works correctly although i cant
test it. I use alsa 0.9x.   Someone with some alsa coding experience
would be helpful here   heh.

i'm currently trying to find someone to build freeamp in windows so i
can test the dsound and win32 outputs ...  

I suspect after the finalized software mixer patch is committed to cvs
that a new version is up to robert.I want to fix this weird ass
theme problem that occurs when you change audio outputs ...sometime
causing the theme to switch to the first theme in the list.  This also
sometimes occurs when you exit freeamp after changing audio outputs.  

On Sun, 2002-06-23 at 18:39, Jason Zubarik wrote:
 So how far off is the next version of FreeAmp, anyway?
 
 
 - Original Message - 
 From: Ed Sweetman [EMAIL PROTECTED]
 To: Robert Kaye [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Sent: Sunday, June 23, 2002 4:24 PM
 Subject: extended software mixer patch
 
 
  This patch aims at removing dependency on hardware mixers to all other
  supported platforms save, irix, solaris, and qnx as there is absolutely
  no way i can test them or know anybody who can.  
  
  This patch is nearly entirely untested...i'm looking for some feedback
  on how it behaves.  
  
  software controlled mixers are as follows
  
  esound,dsound, soundcard (linux and win32 and beos), arts, and alsa
  (even though it's the 0.5x version).   Some tweaks may be needed so any
  modulations in volume when playing audio or other errors should be
  reported so i can follow up on them and tweak the code there.  
  
  
  Also, dead code has not been removed completely yet,  still working on
  that... so use this patch at your own risk.(not ready to be used in
  cvs) 
  
  the june_23.patch patch must be applied prior to this one. 
  
 
 
 ___
 [EMAIL PROTECTED]
 http://www.freeamp.org/mailman/listinfo/freeamp-dev


___
[EMAIL PROTECTED]
http://www.freeamp.org/mailman/listinfo/freeamp-dev