Filewatcher File Search
FTP Search
  
Directory (beta)
  
Content Search (beta)
   
pkg://xltmix-1.1-2.src.rpm:32613/xltmix-1.1.tar.gz  info  downloads

xltmix-1.1/ 40750    766    144           0  6313060573  11013 5ustar  wwgusersxltmix-1.1/COPYING100440    766    144       43076  6313060573  12174 0ustar  wwgusers		    GNU GENERAL PUBLIC LICENSE
		       Version 2, June 1991

 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
                          675 Mass Ave, Cambridge, MA 02139, USA
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

			    Preamble

  The licenses for most software are designed to take away your
freedom to share and change it.  By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users.  This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it.  (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.)  You can apply it to
your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.

  To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.

  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have.  You must make sure that they, too, receive or can get the
source code.  And you must show them these terms so they know their
rights.

  We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.

  Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software.  If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.

  Finally, any free program is threatened constantly by software
patents.  We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary.  To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.

  The precise terms and conditions for copying, distribution and
modification follow.

		    GNU GENERAL PUBLIC LICENSE
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License.  The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language.  (Hereinafter, translation is included without limitation in
the term "modification".)  Each licensee is addressed as "you".

Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope.  The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.

  1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.

You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.

  2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:

    a) You must cause the modified files to carry prominent notices
    stating that you changed the files and the date of any change.

    b) You must cause any work that you distribute or publish, that in
    whole or in part contains or is derived from the Program or any
    part thereof, to be licensed as a whole at no charge to all third
    parties under the terms of this License.

    c) If the modified program normally reads commands interactively
    when run, you must cause it, when started running for such
    interactive use in the most ordinary way, to print or display an
    announcement including an appropriate copyright notice and a
    notice that there is no warranty (or else, saying that you provide
    a warranty) and that users may redistribute the program under
    these conditions, and telling the user how to view a copy of this
    License.  (Exception: if the Program itself is interactive but
    does not normally print such an announcement, your work based on
    the Program is not required to print an announcement.)

These requirements apply to the modified work as a whole.  If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works.  But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.

Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.

In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.

  3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:

    a) Accompany it with the complete corresponding machine-readable
    source code, which must be distributed under the terms of Sections
    1 and 2 above on a medium customarily used for software interchange; or,

    b) Accompany it with a written offer, valid for at least three
    years, to give any third party, for a charge no more than your
    cost of physically performing source distribution, a complete
    machine-readable copy of the corresponding source code, to be
    distributed under the terms of Sections 1 and 2 above on a medium
    customarily used for software interchange; or,

    c) Accompany it with the information you received as to the offer
    to distribute corresponding source code.  (This alternative is
    allowed only for noncommercial distribution and only if you
    received the program in object code or executable form with such
    an offer, in accord with Subsection b above.)

The source code for a work means the preferred form of the work for
making modifications to it.  For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable.  However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.

If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.

  4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License.  Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.

  5. You are not required to accept this License, since you have not
signed it.  However, nothing else grants you permission to modify or
distribute the Program or its derivative works.  These actions are
prohibited by law if you do not accept this License.  Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.

  6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions.  You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.

  7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all.  For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.

If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.

It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices.  Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.

This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.

  8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded.  In such case, this License incorporates
the limitation as if written in the body of this License.

  9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time.  Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

Each version is given a distinguishing version number.  If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation.  If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.

  10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission.  For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this.  Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.

			    NO WARRANTY

  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.

  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

		     END OF TERMS AND CONDITIONS

	Appendix: How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) 19yy  <name of author>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

Also add information on how to contact you by electronic and paper mail.

If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:

    Gnomovision version 69, Copyright (C) 19yy name of author
    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License.  Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.

You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary.  Here is a sample; alter the names:

  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
  `Gnomovision' (which makes passes at compilers) written by James Hacker.

  <signature of Ty Coon>, 1 April 1989
  Ty Coon, President of Vice

This General Public License does not permit incorporating your program into
proprietary programs.  If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library.  If this is what you want to do, use the GNU Library General
Public License instead of this License.
xltmix-1.1/INSTALL100640    766    144       16751  6313060573  12174 0ustar  wwgusersX LessTif Mix Version 1.1

	Copyright (C) 1997  Warren W. Gay VE3WWG

This  program is free software; you can redistribute it and/or modify it
under the  terms  of  the GNU General Public License as published by the
Free Software Foundation version 2 of the License.

This  program  is  distributed  in  the hope that it will be useful, but
WITHOUT   ANY   WARRANTY;   without   even  the   implied   warranty  of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details (see enclosed file COPYING).

You  should have received a copy of the GNU General Public License along
with this  program; if not, write to the Free Software Foundation, Inc.,
675 Mass Ave, Cambridge, MA 02139, USA.

Send correspondance to:

	Warren W. Gay VE3WWG
	5536 Montevideo Road #17
	Mississauga, Ontario L5N 2P4

Email:
	wwg@ica.net			(current ISP of the month :-) )
	bx249@freenet.toronto.on.ca	(backup)

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

PREREQUISITES:

1.	This has been tested on LINUX Kernel 2.0.23 using GCC 2.7.2.
	Apart  from  support  for  LessTif  and  X, this software is
	fairly independent  of the kernel  release.  Just  about any
	release  of  the  LINUX  kernel that supports X and LessTif,
	should be able to run this software (hardware permitting).

2.	X  Server  installed  (XFree86),  since  this  is an X-based
	application  only, even though mixer.c could be carved up to
	make  a  shell based tool independantly  (perhaps at a later
	date).

3.	LessTif  shared  library installed.  This release was tested
	with the LessTif binary release of 0.77 successfully, though
	a  few  very minor issues still require investigation.  That
	release, or a newer release should work just fine.

	Please make sure all C (C++ not used this time)  and LessTif
	shared libraries are properly installed. Don't forget to use
	ldconfig if you've made library changes.

	Alternatively, if you've purchased MOTIF, then you should be
	able  to  use  that  instead (I  no  longer have access to a
	commercial copy of MOTIF).

4.	I  think  GCC 2.7.2 or later is manditory, largely because I
	believe this is a requirement for LessTif.

5.	This   software   only   supports   the  SoundBlaster-16  or
	SoundBlaster-32 (I think). It might support other cards that
	use a CT1745 Mixer chip. Only you know for sure :)


INSTALLATION:
-------------

RESOURCES INSTALLATION NOTE:

	While  this  application  uses  resources, you do NOT need to
	install a resource file for this application. I my view, this
	type  of utility should be wholy contained if possible as one
	simple to install unit, which it is here.

	However,  if  you do wish to customize its look and feel, you
	can of course install your own resource files. To get an idea
	of  what  the  widget  class  names are,  you can examine the
	fallback_resources[] array in the xltmix.c source file.

	Because  of the way fallback resources work, a resource file
	may  have  to be  more explicit in  order  to  override  the
	existing resource definitions. The alternative, is to modify
	the  fallback  resources  in the xltmix.c program, or export
	those to a file, and #if 0 out the fallback resources in the
	program. Recompile, and re-install.

1.	Edit the Makefile to suit (optional):

	ESSENTIAL CHANGES:

	The  most  important configuration parameter is the paramter
	DEV_BASE  which  must  be  set  to the hex port base address
	value. THIS MUST MATCH YOUR SOUNDBLASTER CARD.

		BASE ADDR:	Mixer Ports used:

		220h		224h & 225h
		240h		244h & 245h
		260h		264h & 265h
		280h		284h & 285h

	DEV_BASE=0x0220 is assumed by default (this implies that the
	mixer ports are 0x0224 and 0x0225).

	If you're configurating for a NON-SoundBlaster card, but one
	that _does_ use the CT1745 mixer chip, you need to determine
	the port address for the "index selector" port, and the port
	address  for  its  data port  (normally  this is ports p and
	p+1).  Once  the the "index selector" port is known (say p),
	then compute the base address as p - 4.  I.e.  if your Mixer
	index  selector  port  is  on a weird port address of 0x534,
	then  the  _BASE_ address  you  must  supply is the value of
	0x0534 - 0x0004 which is the hex value 0x0530.

	Other Parameters you may wish to change:

		INSTDIR=/usr/local/bin/

	Determines where the final executable gets installed.

		INSTALL=install

	This determines the install command name to use.

		CPU= -m486

	I  can't  imagine  running  LessTif on a 386, but if you do,
	then  you'll  need  to  change this.  Speed freaks that have
	Pentiums  and Pros, may get  further gains by an appropriate
	adjustment here.

		OPT=	-O2
		STRIP=	strip

	Normally the above two should be uncommented. When activated
	in  this  way, the  debug options must be commented out (see
	next).

		#DEBUG=	-g
		#STRIP= echo

	As  shipped,  these  are commented out, and should stay that
	way unless  you  enjoy hacking  and  using gdb. Another good
	reason  for turning on debug is when you encounter problems,
	and  want to forward a core file to me for debugging.  But I
	am confident that it won't be necessary :)

2.	$ make real_clean

	This deletes any pesky temp. files etc. Its cheap insurance.

3.	$ make

	This  should  build the executable xltmix, which stripped is
	about 25656 bytes in size.  With debug turned on, it will be
	considerably larger.

3.	$ su root

	If you're not root yet.

4.	$ make install

	To  test,  type xltmix from an xterm session.  If no windows
	come up, note the standard error output for problems.

5.	To make the executable setuid root (optional):

	$ chown root /usr/local/bin/xltmix
	$ chmod u+s /usr/local/bin/xltmix

	The  Makefile could have done this for you, but I don't want
	to be blamed for your security problems. This way, I can say
	that _you_ did it, not me.

	This  software  does  not  use a LINUX driver to control the
	mixer chip. This goes directly to the mixer chip by register
	access. This is both good and bad, and sometimes ugly.

	The  good  part  is  that  you  will have complete and utter
	control  of every feature  offered by the CT1745 mixer chip.
	You  won't  ever  need  to resort to Windoze software to set
	something for your SoundBlaster card (hear millions cheer).

	The  bad  thing  is  that  you  _MUST_  get the port address
	correct, since the driver will not be doing it for you. This
	also  makes  this  program less portable, since it will only
	function for those cards that use the CT1745 mixer chip.

	The  ugly  thing  is  that  if  you  get  the  port  address
	incorrect, you  risk  the  integrity  of your system! If you
	give   it  bad  port  registers,  that  overlap  with  other
	hardware, you  may cause a hang, a crash, or under the worst
	case  scenario, even  wipe out  a  disk or more. I assume no
	responsibility  for your guesswork here. Be sure of what you
	are doing, and make sure you have adequate backups!

	The  other  ugly  aspect, is that this forces you to run the
	program  as setuid root,  or  from  root.  If you run your X
	server as root, this may not be a hardship. Setuid programs,
	as you should know, can be security risks.

6.	To  properly  install  it  in your window manager, fvwm2 for
	example,   you  may   want  to   add   a   button   to  your
	/usr/X11R6/lib/X11/fvwm2/.fvwm2rc file, something like:

		*FvwmButtons Mixer NULL Exec "XLTMix" xltmix

	(for   full   X   Window   manager  installation  (fvwm2  or
	otherwise),  please  be  referred  to  your  Window  manager
	documentation  --  the above  example is by no means, a full
	discourse on Window manager startup scripts).

End.
xltmix-1.1/Makefile100640    766    144        4142  6313060573  12552 0ustar  wwgusers.SUFFIXES:	.c .cpp .h .o

# THE FOLLOWING MUST MATCH YOUR PORT SETTING FOR YOUR SOUND BLASTER CARD!
#
# The default base port is 0220 Hex, but yours might be different:
#
#	Base addresses, can be one of the following (unless you got your
#	soldering iron out):
#
#		BASE ADDR:	Mixer Ports used:
#		220h		224h & 225h
#		240h		244h & 245h
#		260h		264h & 265h
#		280h		284h & 285h
#
#	The software compiles by default to use 220h
#
#DEV_BASE= -DDEV_BASE=0x220

#
# Uncomment the following line, _ONLY_ if you have
# read mixer.c and understand the consequences.
#
#INIT_CHK= -DDISABLE_INITCHECK

#
# This determines where the executable xltmix will be installed.
#
INSTDIR= /usr/local/bin/
INSTALL= install

#
# This determines the CPU to compile for. Comment out if you run less than a 486
#
CPU=	-m486

#
# Uncomment for optimization (usually you would also comment out the DEBUG= line though).
# Optionally uncomment this STRIP= line, to strip the executable. Comment out if DEBUG is on.
#
OPT=	-O2
STRIP=	strip

#
# Uncomment for debug mode (comment out the OPT= line, and STRIP lines above). The STRIP=echo
# line should be uncommented for debugging.
#
#DEBUG=	-g
#STRIP= echo

ELF=	-fPIC
INCL=	# -I.
CCOPTS=	-c $(DEBUG)$(OPT) $(CPU) $(ELF) $(DEV_BASE) $(INIT_CHK) -Wstrict-prototypes -Wall
CC=	gcc

OBJS=	mixer.o editvers.o menu.o sliders.o toggle.o xmsprint.o callback.o rpterror.o xltmix.o

.c.o:
	$(CC) $(CCOPTS) $(INCL) $<

all:	mixer.o xltmix

#
#	This one has to have optimize on, even when debugging due to the outb() calls.
#
mixer.o: mixer.c
	$(CC) -O $(CCOPTS) $(INCL) mixer.c

xltmix: $(OBJS)
	rm -f xltmix
	$(CC) $(OBJS) -lXm -lXt -lX11 -o xltmix
	$(STRIP) xltmix
	ls -l xltmix
	@echo "You will need root or setuid root to run xltmix."

install: xltmix
	$(INSTALL) -o root -g root -m 555 xltmix $(INSTDIR)
	@echo
	@echo "Do 'chmod u+s $(INSTDIR)/xltmix' to give"
	@echo "it setuid root privileges that it will require"
	@echo "for general use. As with any setuid program,"
	@echo "you must consider the security ramifications"
	@echo "of doing so."
	@echo

clean:
	rm -f *.o a.out core t.t errs.t

real_clean: clean
	rm -f xltmix
xltmix-1.1/callback.c100440    766    144        6000  6313060573  13003 0ustar  wwgusers/* $Header: /wwg/motif/xltmix/RCS/callback.c,v 1.1 1997/03/16 04:54:57 wwg Exp $
 * Warren W. Gay VE3WWG		Thu Mar  6 21:55:02 1997
 *
 * CALLBACKS
 *
 * 	X LessTif Mix :
 * 
 * 	Copyright (C) 1997  Warren W. Gay VE3WWG
 * 
 * This  program is free software; you can redistribute it and/or modify it
 * under the  terms  of  the GNU General Public License as published by the
 * Free Software Foundation version 2 of the License.
 * 
 * This  program  is  distributed  in  the hope that it will be useful, but
 * WITHOUT   ANY   WARRANTY;   without   even  the   implied   warranty  of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 * Public License for more details (see enclosed file COPYING).
 * 
 * You  should have received a copy of the GNU General Public License along
 * with this  program; if not, write to the Free Software Foundation, Inc.,
 * 675 Mass Ave, Cambridge, MA 02139, USA.
 * 
 * Send correspondance to:
 * 
 * 	Warren W. Gay VE3WWG
 * 	5536 Montevideo Road #17
 *	Mississauga, Ontario L5N 2P4
 * 
 * Email:
 * 	wwg@ica.net			(current ISP of the month :-) )
 * 	bx249@freenet.toronto.on.ca	(backup)
 *
 * $Log: callback.c,v $
 * Revision 1.1  1997/03/16 04:54:57  wwg
 * Initial revision
 *
 */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <assert.h>

#include <Xm/Xm.h>
#include <Xm/Label.h>
#include <Xm/ScrollBar.h>
#include <Xm/RowColumn.h>
#include <Xm/Frame.h>

#include "xltmix.h"

static char rcsid[] = "@(#)callback.c $Revision: 1.1 $";

/*
 * This callback is made when the Help->About dialog has its OK button
 * clicked. This call pops-down the dialog.
 */
void
AboutDlgOkCB(Widget w,XtPointer client_data,XtPointer call_data) {
	if ( XtIsManaged(wAboutDlg) )			/* Is this managed? */
		XtUnmanageChild(wAboutDlg);		/* No, unmanage so it pops-down */
}

/*
 * This callback is made when the Help->About dialog is to be
 * popped-up.
 */
void
AboutCB(Widget w,XtPointer client_data,XtPointer call_data) {
	fprintf(stderr,"Copyright (C) 1997 Warren W. Gay VE3WWG\n");

	if ( XtIsManaged(wAboutDlg) )			/* Is this managed yet? */
		return;					/* The dialog is already in use (managed) */

	XtVaSetValues(wAboutDlg,XmNmessageString,sAboutDlgMessage,NULL);
	XtManageChild(wAboutDlg);			/* Make it pop up */
}

/*
 * This callback is made when File->Exit has been selected.
 */
void
ExitCB(Widget w,XtPointer client_data,XtPointer call_data) {
	exit(0);					/* Bail out, with normal zero exit code */
}

/*
 * This callback is called when the user presses OK in the error
 * dialog. All we do here is to unmanage the error dialog, so that
 * it goes invisible, until its needed again.
 */
void
ExitDlgCB(Widget w,XtPointer client_data,XtPointer call_data) {

	if ( XtIsManaged(wErrDlg) )			/* Is this dialog managed yet? */
		XtUnmanageChild(wErrDlg);		/* Yes, so pop this down by unmanaging it */

	if ( bFatal )					/* Was a fatal error registered? */
		exit(2);				/* Yes, abandon ship! */
}

/* $Source: /wwg/motif/xltmix/RCS/callback.c,v $ */
xltmix-1.1/editvers.c100440    766    144        4366  6313060573  13111 0ustar  wwgusers/* $Header: /wwg/motif/xltmix/RCS/editvers.c,v 1.1 1997/03/16 04:55:05 wwg Exp $
 * Warren W. Gay VE3WWG		Thu Mar  6 22:05:57 1997
 *
 * VERSION EDITING
 *
 * 	X LessTif Mix :
 * 
 * 	Copyright (C) 1997  Warren W. Gay VE3WWG
 * 
 * This  program is free software; you can redistribute it and/or modify it
 * under the  terms  of  the GNU General Public License as published by the
 * Free Software Foundation version 2 of the License.
 * 
 * This  program  is  distributed  in  the hope that it will be useful, but
 * WITHOUT   ANY   WARRANTY;   without   even  the   implied   warranty  of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 * Public License for more details (see enclosed file COPYING).
 * 
 * You  should have received a copy of the GNU General Public License along
 * with this  program; if not, write to the Free Software Foundation, Inc.,
 * 675 Mass Ave, Cambridge, MA 02139, USA.
 * 
 * Send correspondance to:
 * 
 * 	Warren W. Gay VE3WWG
 * 	5536 Montevideo Road #17
 *	Mississauga, Ontario L5N 2P4
 * 
 * Email:
 * 	wwg@ica.net			(current ISP of the month :-) )
 * 	bx249@freenet.toronto.on.ca	(backup)
 *
 * $Log: editvers.c,v $
 * Revision 1.1  1997/03/16 04:55:05  wwg
 * Initial revision
 *
 */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <Xm/Xm.h>
#include "xltmix.h"

static char rcsid[] = "@(#)editvers.c $Revision: 1.1 $";

/*
 * This routine edits char vers[] to remove the pesky RCS '$' from "$ Revision $"
 * in the string.
 */
void
EditVersionInit(void) {
	char buf[40], *cp;
	char *dp = buf;

	if ( (cp = strchr(vers,' ')) == NULL )
		return;					/* bail out if we don't find the space */
	for ( ++cp; *cp && *cp != ' ' && *cp != '$'; )
		*dp++ = *cp++;				/* Copy only the version number */
	*dp = 0;					/* NUL terminate */
	strcpy(vers,buf);				/* Copy edited version back */
}

/*
 * This function returns a copy of pString, which is copied to pBuffer. Any occurance
 * of '$' is replaced with a version number.
 */ 
char *
EditVersion(char *pString,char *pBuffer) {
	char *bp = pBuffer;

	for ( ; *pString; ++pString )
		if ( *pString == '$' ) {
			strcpy(bp,vers);
			bp += strlen(vers);
		} else	*bp++ = *pString;
	*bp = 0;

	return pBuffer;
}

/* $Source: /wwg/motif/xltmix/RCS/editvers.c,v $ */
xltmix-1.1/menu.c100440    766    144        6633  6313060573  12227 0ustar  wwgusers/* $Header: /wwg/motif/xltmix/RCS/menu.c,v 1.1 1997/03/16 04:55:11 wwg Exp $
 * Warren W. Gay VE3WWG		Thu Feb 13 21:10:04 1997
 *
 * Menu related functions:
 *
 * 	X LessTif Mix :
 * 
 * 	Copyright (C) 1997  Warren W. Gay VE3WWG
 * 
 * This  program is free software; you can redistribute it and/or modify it
 * under the  terms  of  the GNU General Public License as published by the
 * Free Software Foundation version 2 of the License.
 * 
 * This  program  is  distributed  in  the hope that it will be useful, but
 * WITHOUT   ANY   WARRANTY;   without   even  the   implied   warranty  of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 * Public License for more details (see enclosed file COPYING).
 * 
 * You  should have received a copy of the GNU General Public License along
 * with this  program; if not, write to the Free Software Foundation, Inc.,
 * 675 Mass Ave, Cambridge, MA 02139, USA.
 * 
 * Send correspondance to:
 * 
 * 	Warren W. Gay VE3WWG
 * 	5536 Montevideo Road #17
 *	Mississauga, Ontario L5N 2P4
 * 
 * Email:
 * 	wwg@ica.net			(current ISP of the month :-) )
 * 	bx249@freenet.toronto.on.ca	(backup)
 *
 * $Log: menu.c,v $
 * Revision 1.1  1997/03/16 04:55:11  wwg
 * Initial revision
 *
 */
static char rcsid[] = "@(#)menu.c $Revision: 1.1 $";

#include <stdio.h>
#include <stdarg.h>
#include <Xm/Xm.h>
#include <Xm/RowColumn.h>
#include <Xm/PushB.h>
#include <Xm/CascadeB.h>
#include <Xm/ToggleB.h>
#include "xltmix.h"

/*
 * This function creates a pulldown menu:
 */
void
CreateMenu(Widget wMenuBar,Widget *wPulldown,char *namePulldown,Widget *wCascade,char *nameCascade,...) {
	Arg al[32];
	Cardinal ac;
	va_list ap;
	Widget wChoice;
		/* Varargs repeating group: */
	char *nameChoice;				/* Class name of the item to select */
	char menu_type;					/* 'M' for normal menu, 'T'/'t' for toggle item */
	XtCallbackProc callback;			/* Callback procedure */
	Widget *wPointer;				/* Pointer to widget to return */
	Boolean tf;					/* Boolean value for 'T' and 't' types: */

	va_start(ap,nameCascade);

	ac = 0;
	*wPulldown = XmCreatePulldownMenu(wMenuBar,namePulldown,al,ac);

	ac = 0;
	XtSetArg(al[ac],XmNsubMenuId,*wPulldown); ++ac;
	*wCascade = XmCreateCascadeButton(wMenuBar,nameCascade,al,ac);

	nameChoice = va_arg(ap,char *);

	while ( nameChoice != NULL ) {

		menu_type = va_arg(ap,char);		/* Get 'M' or 'T' */
		callback = va_arg(ap,XtCallbackProc);	/* Get callback address or NULL ptr */
		wPointer = va_arg(ap,Widget *);		/* Get address so we can return widget */

		switch ( menu_type ) {
		case 'M' :
			ac = 0;
			*wPointer = wChoice = XmCreatePushButton(*wPulldown,nameChoice,al,ac);
			if ( callback != NULL )
				XtAddCallback(wChoice,XmNactivateCallback,callback,NULL);
			break;
		case 'T' :				/* Default is TRUE */
		case 't' :				/* Default is FALSE */
			tf = menu_type == 'T' ? TRUE : FALSE;
		        ac = 0;
	                XtSetArg(al[ac],XmNindicatorOn,TRUE); ++ac;
	                XtSetArg(al[ac],XmNset,tf); ++ac;			
                        XtSetArg(al[ac],XmNindicatorType,XmN_OF_MANY); ++ac;
			*wPointer = wChoice = XmCreateToggleButton(*wPulldown,nameChoice,al,ac);
			if ( callback != NULL )
				XtAddCallback(wChoice,XmNvalueChangedCallback,callback,NULL);
			break;
		default :
			abort();			/* This should never happen */
		}
		XtManageChild(wChoice);

		nameChoice = va_arg(ap,char *);
	}
	XtManageChild(*wCascade);
	va_end(ap);
}

/* $Source: /wwg/motif/xltmix/RCS/menu.c,v $ */
xltmix-1.1/mixer.c100440    766    144       23577  6313060573  12435 0ustar  wwgusers/* $Header: /wwg/motif/xltmix/RCS/mixer.c,v 1.1 1997/03/16 04:54:50 wwg Exp $
 * Warren W. Gay VE3WWG		Thu Mar  6 22:51:34 1997
 *
 * MIXER FUNCTIONS
 *
 * 	X LessTif Mix :
 * 
 * 	Copyright (C) 1997  Warren W. Gay VE3WWG
 * 
 * This  program is free software; you can redistribute it and/or modify it
 * under the  terms  of  the GNU General Public License as published by the
 * Free Software Foundation version 2 of the License.
 * 
 * This  program  is  distributed  in  the hope that it will be useful, but
 * WITHOUT   ANY   WARRANTY;   without   even  the   implied   warranty  of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 * Public License for more details (see enclosed file COPYING).
 * 
 * You  should have received a copy of the GNU General Public License along
 * with this  program; if not, write to the Free Software Foundation, Inc.,
 * 675 Mass Ave, Cambridge, MA 02139, USA.
 * 
 * Send correspondance to:
 * 
 * 	Warren W. Gay VE3WWG
 * 	5536 Montevideo Road #17
 *	Mississauga, Ontario L5N 2P4
 * 
 * Email:
 * 	wwg@ica.net			(current ISP of the month :-) )
 * 	bx249@freenet.toronto.on.ca	(backup)
 *
 * $Log: mixer.c,v $
 * Revision 1.1  1997/03/16 04:54:50  wwg
 * Initial revision
 *
 */
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <sys/types.h>
#include <linux/soundcard.h>
#include <asm/io.h>

#include <Xm/Xm.h>

#include "xltmix.h"

static char rcsid[] = "@(#)mixer.c $Revision: 1.1 $";

#ifndef DISABLE_INITCHECK
static int MixIdentified(void);				/* Optional verification of initialization */
#endif

/*
 * Logical Mixer Register Table Entry:
 */
typedef struct {
	unsigned	x;				/* Port index */
	unsigned	mask;				/* Mask */
	unsigned	x2;				/* 0 or index of related register */
	unsigned	shift;				/* Shift count, bits */
	unsigned	deflt;				/* Default value */
} MixTab;

/*
 * Logical Mixer Registers:
 */
static MixTab MixRegs[] = {
	{ 0x00, 0xFF, MIXREG_NONE, 0, 0 },		/* MIXREG_RESET */
	{ 0x04, 0xF0, MIXREG_VOICE_R4, 4, 12 },		/* MIXREG_VOICE_L4 */
	{ 0x04, 0x0F, MIXREG_VOICE_L4, 0, 12 },		/* MIXREG_VOICE_R4 */
	{ 0x0A, 0x07, MIXREG_NONE, 0, 0 },		/* MIXREG_MIC_4 */
	{ 0x22, 0xF0, MIXREG_MSTR_R4, 4, 12 },		/* MIXREG_MSTR_L4 */
	{ 0x22, 0x0F, MIXREG_MSTR_L4, 0, 12 },		/* MIXREG_MSTR_R4 */
	{ 0x26, 0xF0, MIXREG_MIDI_R4, 4, 12 },		/* MIXREG_MIDI_L4 */
	{ 0x26, 0x0F, MIXREG_MIDI_L4, 0, 12 },		/* MIXREG_MIDI_R4 */
	{ 0x28, 0xF0, MIXREG_CD_R4, 4, 0 },		/* MIXREG_CD_L4 */
	{ 0x28, 0x0F, MIXREG_CD_L4, 0, 0 },		/* MIXREG_CD_R4 */
	{ 0x2E, 0xF0, MIXREG_LINE_R4, 4, 0 },		/* MIXREG_LINE_L4 */
	{ 0x2E, 0x0F, MIXREG_LINE_L4, 0, 0 },		/* MIXREG_LINE_R4 */
	{ 0x30, 0xF8, MIXREG_NONE, 3, 24 },		/* MIXREG_MSTR_L5 */
	{ 0x31, 0xF8, MIXREG_NONE, 3, 24 },		/* MIXREG_MSTR_R5 */
	{ 0x32, 0xF8, MIXREG_NONE, 3, 24 },		/* MIXREG_VOICE_L5 */
	{ 0x33, 0xF8, MIXREG_NONE, 3, 24 },		/* MIXREG_VOICE_R5 */
	{ 0x34, 0xF8, MIXREG_NONE, 3, 24 },		/* MIXREG_MIDI_L5 */
	{ 0x35, 0xF8, MIXREG_NONE, 3, 24 },		/* MIXREG_MIDI_R5 */
	{ 0x36, 0xF8, MIXREG_NONE, 3, 0 },		/* MIXREG_CD_L5 */
	{ 0x37, 0xF8, MIXREG_NONE, 3, 0 },		/* MIXREG_CD_R5 */
	{ 0x38, 0xF8, MIXREG_NONE, 3, 0 },		/* MIXREG_LINE_L5 */
	{ 0x39, 0xF8, MIXREG_NONE, 3, 0 },		/* MIXREG_LINE_R5 */
	{ 0x3A, 0xF8, MIXREG_NONE, 3, 0 },		/* MIXREG_MIC_5 */
	{ 0x3B, 0xC0, MIXREG_NONE, 6, 0 },		/* MIXREG_SPKR_2 */
	{ 0x3C, 0x1F, MIXREG_NONE, 0, 0x1F },		/* MIXREG_OUTMIX_SW */
	{ 0x3D, 0x7F, MIXREG_NONE, 0, 0x15 },		/* MIXREG_INMIX_SW_L */
	{ 0x3E, 0x7F, MIXREG_NONE, 0, 0x0B },		/* MIXREG_INMIX_SW_R */
	{ 0x3F, 0xC0, MIXREG_NONE, 6, 0 },		/* MIXREG_IGAIN_L2 */
	{ 0x40, 0xC0, MIXREG_NONE, 6, 0 },		/* MIXREG_IGAIN_R2 */
	{ 0x41, 0xC0, MIXREG_NONE, 6, 0 },		/* MIXREG_OGAIN_L2 */
	{ 0x42, 0xC0, MIXREG_NONE, 6, 0 },		/* MIXREG_OGAIN_R2 */
	{ 0x43, 0x01, MIXREG_NONE, 0, 0 },		/* MIXREG_AGC */
	{ 0x44, 0xF0, MIXREG_NONE, 4, 8 },		/* MIXREG_TREBLE_L4 */
	{ 0x45, 0xF0, MIXREG_NONE, 4, 8 },		/* MIXREG_TREBLE_R4 */
	{ 0x46, 0xF0, MIXREG_NONE, 4, 8 },		/* MIXREG_BASS_L4 */
	{ 0x47, 0xF0, MIXREG_NONE, 4, 8 },		/* MIXREG_BASS_R4 */
};

#ifndef DISABLE_INITCHECK
/*
 * Check List for MixIdentified():
 */
static unsigned CheckList[] = {
	MIXREG_MSTR_L5, MIXREG_MSTR_R5,
	MIXREG_VOICE_L5, MIXREG_VOICE_R5,
	MIXREG_MIDI_L5, MIXREG_MIDI_R5,
	MIXREG_CD_L5, MIXREG_CD_R5,
	MIXREG_LINE_L5, MIXREG_LINE_R5,
	MIXREG_MIC_5,
	MIXREG_SPKR_2,
	MIXREG_OUTMIX_SW,
	MIXREG_INMIX_SW_L, MIXREG_INMIX_SW_R,
	MIXREG_IGAIN_L2, MIXREG_IGAIN_R2,
	MIXREG_OGAIN_L2, MIXREG_OGAIN_R2,
	MIXREG_AGC,
	MIXREG_TREBLE_L4, MIXREG_TREBLE_R4,
	MIXREG_BASS_L4, MIXREG_BASS_R4,
	MIXREG_NONE
};
#endif /* DISABLE_INITCHECK */

/*
 * Mixer initialization 'main' routine:
 */
int
MixInit(void) {

	/*
	 * In order for this program to function, we must have direct access to the
	 * two mixer ports. To do this we need to be either running as root, or have
	 * setuid 'root' on the executable. Once we've got access from the kernel, we
	 * can switch back to ourselves (this is done in the main program in xltmix.c)
	 */
	if ( ioperm(DEV_INDX,2,1) ) {			/* Gain access to our two mixer ports */
		/*
		 * We were not root, nor did we did not have setuid 'root'.
		 */
		sprintf(fatalMsg,"%s: accessing Mixer ports 0x%04X & 0x%04X\n"
			"Try running as root, or setuid root on executable.",
			sys_errlist[errno],
			(unsigned)DEV_INDX,
			(unsigned)DEV_DATA);
		bPortAccessFailed = True;
		return -1;
	}

	/*
	 * This next step is put in for [some] safety and diagnostic purposes: it
	 * will cause a minor click in the speakers, and once you've verified that
	 * this software works in your situation, you might want to disable this
	 * call entirely. Use -DDISPABLE_INITCHECK for this purpose, and recompile.
	 */
#ifndef DISABLE_INITCHECK
	(void) MixIdentified();
#endif
	return 0;
}

#if 0
void							/* Not currently used, but this is how it */
MixerClose(void) {					/* would be done. */
	ioperm(DEV_INDX,2,0);				/* Ignore errors, though there shouldn't be */
}
#endif

/*
 * Raw read of a mixer register:
 */
static unsigned
MixerReadReg(unsigned x) {
	int i;
	int t = 0;

	outb(x,DEV_INDX);				/* Select mixer register to read */
	for ( i=0; i<=7; ++i )				/* Lengthen this loop if your CPU gets too fast */
		t += inb(DEV_DATA);			/* Kill time */
	i = inb(DEV_DATA);				/* Do the real data read */
	return (unsigned) i;				/* Return the data value */
}

/*
 * Raw write of a mixer register:
 */
static void
MixerWriteReg(unsigned x,unsigned b) {
	int i;
	int t = 0;

	outb(x,DEV_INDX);				/* Select mixer register to write */
	for ( i=0; i<=7; ++i )				/* Lengthen this loop if your CPU gets too fast */
		t += inb(DEV_DATA);			/* Kill time */
	outb(b,DEV_DATA);				/* Write the data now */
}

/*
 * Get the LOGICAL mixer register value:
 */
unsigned
MixGetReg(unsigned reg) {
	unsigned b;

	b = MixerReadReg(MixRegs[reg].x) & MixRegs[reg].mask;

	if ( MixRegs[reg].shift > 0 )
		b >>= MixRegs[reg].shift;		/* Shift into position */

	return b;
}

/*
 * Write the LOGICAL mixer register value: Note that in this routine, we have
 * to be concious of paired registers if you want to use the compatibility
 * registers. In the end, none of the paired registers got used, but this
 * code should work for both the newer and older logical registers.
 */
void
MixPutReg(unsigned reg,unsigned b) {
	unsigned t, x;

	if ( (x = MixRegs[reg].x2) != MIXREG_NONE )	/* Is there another register paired with this? */
		t = MixerReadReg(MixRegs[x].x) & MixRegs[x].mask; /* Yes, then get its value first */
	else	t = 0x00;				/* No, we can assume value zero */

	if ( MixRegs[reg].shift > 0 )			/* Does this one get shifted? */
		b <<= MixRegs[reg].shift;		/* Yes, shift left */
	b &= MixRegs[reg].mask;				/* Now mask it */

	t |= b;						/* Or in other paired register, if any */

	MixerWriteReg(MixRegs[reg].x,t);		/* Send to physical register now */
}

/*
 * Mixer initialization check procedure:
 *
 * This function saves the current settings of the mixer, and then applies a mixer RESET.
 * After this hardware reset, if the mixer port has been configured properly, and the
 * proper hardware matches, then all mixer register values after the reset should contain
 * default values which we check for here. If the values don't match defaults, then there
 * are two possibilities:
 *
 *	1.	The mixer port given is invalid:
 *		Action: Recompile with -DDEV_BASE=0xXXXX with the correct port value,
 *			in hex, subsituted for XXXX.
 *
 *	2.	The port is valid, but the chip is perhaps a clone of the original
 *		CT1745 Mixer chip, and does not fully support the default values after
 *		a reset.
 *		Action:	Compile with -DDISABLE_INITCHK
 */
#ifndef DISABLE_INITCHECK
static int
MixIdentified(void) {
	unsigned x;
	unsigned b;
	volatile unsigned z;
	unsigned saved[sizeof CheckList/sizeof CheckList[0]];

	/*
	 * Save all register settings: Note that if the port address is given
	 * incorrectly, this could cause the system to crash here.
	 */
	for ( x=0; CheckList[x] != MIXREG_NONE; ++x )
		saved[x] = MixGetReg(CheckList[x]);

	/*
	 * Reset the mixer, and pause:
	 */
	MixerWriteReg(MixRegs[MIXREG_RESET].x,0x00);	/* Perform Mixer reset */
	for ( x=0; x < 20; ++x )
		z = (unsigned) ((float) 22.0 / 7.0);	/* Waste time for reset */

	/*
	 * Now test reset values of the registers against the known defaults:
	 */
	for ( x=0; CheckList[x] != MIXREG_NONE; ++x ) {
		b = MixGetReg(CheckList[x]);
		if ( b != MixRegs[CheckList[x]].deflt ) {
			sprintf(fatalMsg,"Failed validation of mixer register (x=%u)\n"
				"in %s line %u. Because of this, it seems that you probably\n"
				"do not have a SoundBlaster-16 or SoundBlaster-32 card,\n"
				"or your base port number setting of 0x%04X is incorrect.\n"
				"(bad port numbers can be fatal to your system's integrity!)",
				(unsigned)x,
				__FILE__,__LINE__-7,
				DEV_BASE);
			bPortInvalid = True;
			return -1;
		}
	}

	/*
	 * Restore all register settings:
	 */
	for ( x=0; CheckList[x] != MIXREG_NONE; ++x )
		MixPutReg(CheckList[x],saved[x]);

	return 0;
}
#endif	/* DISABLE_INITCHECK */

/* $Sound$ */
xltmix-1.1/rpterror.c100440    766    144        4755  6313060573  13145 0ustar  wwgusers/* $Header: /wwg/motif/xltmix/RCS/rpterror.c,v 1.1 1997/03/16 04:55:35 wwg Exp $
 * Warren W. Gay VE3WWG		Thu Mar  6 21:59:54 1997
 *
 * REPORT ERRORS
 *
 * 	X LessTif Mix :
 * 
 * 	Copyright (C) 1997  Warren W. Gay VE3WWG
 * 
 * This  program is free software; you can redistribute it and/or modify it
 * under the  terms  of  the GNU General Public License as published by the
 * Free Software Foundation version 2 of the License.
 * 
 * This  program  is  distributed  in  the hope that it will be useful, but
 * WITHOUT   ANY   WARRANTY;   without   even  the   implied   warranty  of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 * Public License for more details (see enclosed file COPYING).
 * 
 * You  should have received a copy of the GNU General Public License along
 * with this  program; if not, write to the Free Software Foundation, Inc.,
 * 675 Mass Ave, Cambridge, MA 02139, USA.
 * 
 * Send correspondance to:
 * 
 * 	Warren W. Gay VE3WWG
 * 	5536 Montevideo Road #17
 *	Mississauga, Ontario L5N 2P4
 * 
 * Email:
 * 	wwg@ica.net			(current ISP of the month :-) )
 * 	bx249@freenet.toronto.on.ca	(backup)
 *
 * $Log: rpterror.c,v $
 * Revision 1.1  1997/03/16 04:55:35  wwg
 * Initial revision
 *
 */
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <assert.h>

#include <Xm/Xm.h>
#include <Xm/MessageB.h>

#include "xltmix.h"

static char rcsid[] = "@(#)rpterror.c $Revision: 1.1 $";

/*
 * This function initiates the creation of an error dialog with
 * a meaningful error text and an OK button. Note that the dialog
 * box is not operationaly until we return back to the main loop.
 */
void
ReportError(const char *file,unsigned lno,const char *format,...) {
	char buf[512];
	XmString s;					/* XmString form of message */
	va_list ap;

	va_start(ap,format);
	vfprintf(stderr,format,ap);
	if ( file != NULL )
		fprintf(stderr," (%s line %u)\n",file,lno);
	
	if ( XtIsManaged(wErrDlg) )
		goto xit;				/* The dialog is already in use */

	/*
	 * Set the Error Dialog message text, and manage it so that it pops up:
	 */
	vsprintf(buf,format,ap);			/* Format into the buffer */
	s = XmStringCreateLtoR((char *)buf,XmSTRING_DEFAULT_CHARSET); /* We need an XmString */
	XtVaSetValues(wErrDlg,XmNmessageString,s,NULL);	/* Put msg in there */
	XmStringFree(s);				/* Release the string */

	XtManageChild(wErrDlg);				/* Make it pop up */

xit:	va_end(ap);
}

/* $Source: /wwg/motif/xltmix/RCS/rpterror.c,v $ */

xltmix-1.1/sliders.c100440    766    144       16031  6313060573  12741 0ustar  wwgusers/* $Header: /wwg/motif/xltmix/RCS/sliders.c,v 1.1 1997/03/16 04:55:52 wwg Exp $
 * Warren W. Gay VE3WWG		Thu Mar  6 21:49:46 1997
 *
 * SLIDERS (Volume Scrollbars)
 *
 * 	X LessTif Mix :
 * 
 * 	Copyright (C) 1997  Warren W. Gay VE3WWG
 * 
 * This  program is free software; you can redistribute it and/or modify it
 * under the  terms  of  the GNU General Public License as published by the
 * Free Software Foundation version 2 of the License.
 * 
 * This  program  is  distributed  in  the hope that it will be useful, but
 * WITHOUT   ANY   WARRANTY;   without   even  the   implied   warranty  of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 * Public License for more details (see enclosed file COPYING).
 * 
 * You  should have received a copy of the GNU General Public License along
 * with this  program; if not, write to the Free Software Foundation, Inc.,
 * 675 Mass Ave, Cambridge, MA 02139, USA.
 * 
 * Send correspondance to:
 * 
 * 	Warren W. Gay VE3WWG
 * 	5536 Montevideo Road #17
 *	Mississauga, Ontario L5N 2P4
 * 
 * Email:
 * 	wwg@ica.net			(current ISP of the month :-) )
 * 	bx249@freenet.toronto.on.ca	(backup)
 *
 * $Log: sliders.c,v $
 * Revision 1.1  1997/03/16 04:55:52  wwg
 * Initial revision
 *
 */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <assert.h>

#include <Xm/Xm.h>
#include <Xm/Label.h>
#include <Xm/ScrollBar.h>
#include <Xm/RowColumn.h>
#include <Xm/Frame.h>

#include "xltmix.h"

static char rcsid[] = "@(#)sliders.c $Revision: 1.1 $";

/*
 * The value of a scroll bar changed: Note the new value, and update the mixer
 * chip based upon the new scroll bar setting.
 */
static void
ChangedSlider_CB(Widget w,XtPointer client_data,XtPointer call_data) {
	XmScrollBarCallbackStruct *Ptr = (XmScrollBarCallbackStruct *)call_data;
	DevSliders *pSlider = (DevSliders *)client_data;
	unsigned xLR;

	if ( w == pSlider->Left ) {			/* Left control of a pair? */
		pSlider->vLeft = Ptr->value;		/* Yes, save lefty value */
		xLR = pSlider->xL;			/* and pick the mixer register for left */
	} else	{
		pSlider->vRight = Ptr->value;		/* No, save right handed value */
		xLR = pSlider->xR;			/* and use right handed mixeer register */
	}

	MixPutReg(xLR,(unsigned)Ptr->value);		/* Now put setting into mixer chip */
}

/*
 * This internal routine updates a scroll bar with the current value found in the
 * mixer chip. This is usually only done once at initial startup for each mixer control.
 */
static void
_PutSlider(Widget w,unsigned xLR) {
	unsigned mix_value = MixGetReg(xLR);

	XtVaSetValues(w,XmNvalue,(int)mix_value,NULL);
}

/*
 * Add all slider callbacks:
 */
static void
_AddCallback(Widget w,XtCallbackProc callback_proc,XtPointer client_data) {
	XtAddCallback(w,XmNdecrementCallback,callback_proc,client_data);
	XtAddCallback(w,XmNdragCallback,callback_proc,client_data);
	XtAddCallback(w,XmNincrementCallback,callback_proc,client_data);
	XtAddCallback(w,XmNpageDecrementCallback,callback_proc,client_data);
	XtAddCallback(w,XmNpageIncrementCallback,callback_proc,client_data);
	XtAddCallback(w,XmNtoBottomCallback,callback_proc,client_data);
	XtAddCallback(w,XmNtoTopCallback,callback_proc,client_data);
}

/*
 * Create a pair of left+right sliders, or a singular slider. Does the frames etc.
 */
Widget
CreateSliders(Widget parent,char *class,DevSliders *pSliders,short bStereo,int max,unsigned xL,unsigned xR) {
	Arg al[20];					/* Arg list */
	Cardinal ac;					/* Args count */
	char buf[80];
	static int slider_height = 150;			/* Slider's height in pixels */
	static int slider_width = 20;			/* Slider's width in pixels */
	int slider_size = (max+1) / 4;			/* Compute slider size as 1/4th */

	if ( !slider_size )
		slider_size = 1;			/* Insist on 1 pixel minimum */

	/*
	 * Initialize
	 */
	pSliders->vLeft = pSliders->vRight = 0;
	pSliders->max = max;
	pSliders->xL = xL;
	pSliders->xR = xR;

	/*
	 * The outer frame of the pair of controls
	 */
	sprintf(buf,"%s_frame",class);
	ac = 0;
	XtSetArg(al[ac],XmNmarginHeight,frame_margin); ++ac;
	XtSetArg(al[ac],XmNmarginWidth,frame_margin); ++ac;
	pSliders->Frame = XmCreateFrame(parent,buf,al,ac);
	XtManageChild(pSliders->Frame);

	/*
	 * Vertical container for label + controls:
	 */
	sprintf(buf,"%s_rc",class);
	ac = 0;
	XtSetArg(al[ac],XmNorientation,XmVERTICAL); ++ac;
	XtSetArg(al[ac],XmNpacking,XmPACK_TIGHT); ++ac;
	pSliders->RC = XmCreateRowColumn(pSliders->Frame,buf,al,ac);
	XtManageChild(pSliders->RC);

	/*
	 * Label for the pair of sliders:
	 */
	sprintf(buf,"%s_lbl",class);
	ac = 0;
	pSliders->Lbl = XmCreateLabel(pSliders->RC,buf,al,ac);
	XtManageChild(pSliders->Lbl);

	pSliders->RC2 = 0UL;
	
	/*
	 * Now create stereo pair, or a singular control:
	 */
	if ( bStereo ) {
		/*
		 * Left and right level controls: this row/col container holds them
		 */
		sprintf(buf,"%s_rc2",class);
		ac = 0;
		XtSetArg(al[ac],XmNorientation,XmHORIZONTAL); ++ac;
		XtSetArg(al[ac],XmNpacking,XmPACK_COLUMN); ++ac;
		pSliders->RC2 = XmCreateRowColumn(pSliders->RC,buf,al,ac);
		XtManageChild(pSliders->RC2);
		
		/*
		 * Create the left control:
		 */
		sprintf(buf,"%s_L",class);
		ac = 0;
		XtSetArg(al[ac],XmNheight,slider_height); ++ac;
		XtSetArg(al[ac],XmNwidth,slider_width); ++ac;
		XtSetArg(al[ac],XmNsliderSize,slider_size); ++ac;
		XtSetArg(al[ac],XmNminimum,0); ++ac;
		XtSetArg(al[ac],XmNmaximum,pSliders->max+slider_size); ++ac;
		XtSetArg(al[ac],XmNprocessingDirection,XmMAX_ON_TOP); ++ac;
		pSliders->Left = XmCreateScrollBar(pSliders->RC2,buf,al,ac);
		XtManageChild(pSliders->Left);
		_AddCallback(pSliders->Left,ChangedSlider_CB,(XtPointer)pSliders);

		_PutSlider(pSliders->Left,pSliders->xL);	/* Initialize setting of left control */

		/*
		 * Create the right control:
		 */
		sprintf(buf,"%s_R",class);
		ac = 0;
		XtSetArg(al[ac],XmNheight,slider_height); ++ac;
		XtSetArg(al[ac],XmNwidth,slider_width); ++ac;
		XtSetArg(al[ac],XmNsliderSize,slider_size); ++ac;
		XtSetArg(al[ac],XmNminimum,0); ++ac;
		XtSetArg(al[ac],XmNmaximum,pSliders->max+slider_size); ++ac;
		XtSetArg(al[ac],XmNprocessingDirection,XmMAX_ON_TOP); ++ac;
		pSliders->Right = XmCreateScrollBar(pSliders->RC2,buf,al,ac);
		XtManageChild(pSliders->Right);
		_AddCallback(pSliders->Right,ChangedSlider_CB,(XtPointer)pSliders);

		_PutSlider(pSliders->Right,pSliders->xR);	/* Initialize setting of right control */

	} else	{
		/*
		 * Singular scroll bar:
		 */
		sprintf(buf,"%s_sb",class);
		ac = 0;
		XtSetArg(al[ac],XmNheight,slider_height); ++ac;
		XtSetArg(al[ac],XmNwidth,slider_width); ++ac;
		XtSetArg(al[ac],XmNsliderSize,slider_size); ++ac;
		XtSetArg(al[ac],XmNminimum,0); ++ac;
		XtSetArg(al[ac],XmNmaximum,pSliders->max+slider_size); ++ac;
		XtSetArg(al[ac],XmNprocessingDirection,XmMAX_ON_TOP); ++ac;
		pSliders->Left = XmCreateScrollBar(pSliders->RC,buf,al,ac);
		XtManageChild(pSliders->Left);
		_AddCallback(pSliders->Left,ChangedSlider_CB,(XtPointer)pSliders);

		_PutSlider(pSliders->Left,pSliders->xL);	/* Initialize setting of control */
		pSliders->Right = 0UL;				/* No right control here */
	}

	return pSliders->Frame;
}

/* $Source: /wwg/motif/xltmix/RCS/sliders.c,v $ */
xltmix-1.1/toggle.c100440    766    144       16271  6313060573  12563 0ustar  wwgusers/* $Header: /wwg/motif/xltmix/RCS/toggle.c,v 1.1 1997/03/16 04:55:59 wwg Exp $
 * Warren W. Gay VE3WWG		Thu Mar  6 21:39:42 1997
 *
 * TOGGLES CODE
 *
 * 	X LessTif Mix :
 * 
 * 	Copyright (C) 1997  Warren W. Gay VE3WWG
 * 
 * This  program is free software; you can redistribute it and/or modify it
 * under the  terms  of  the GNU General Public License as published by the
 * Free Software Foundation version 2 of the License.
 * 
 * This  program  is  distributed  in  the hope that it will be useful, but
 * WITHOUT   ANY   WARRANTY;   without   even  the   implied   warranty  of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 * Public License for more details (see enclosed file COPYING).
 * 
 * You  should have received a copy of the GNU General Public License along
 * with this  program; if not, write to the Free Software Foundation, Inc.,
 * 675 Mass Ave, Cambridge, MA 02139, USA.
 * 
 * Send correspondance to:
 * 
 * 	Warren W. Gay VE3WWG
 * 	5536 Montevideo Road #17
 *	Mississauga, Ontario L5N 2P4
 * 
 * Email:
 * 	wwg@ica.net			(current ISP of the month :-) )
 * 	bx249@freenet.toronto.on.ca	(backup)
 *
 * $Log: toggle.c,v $
 * Revision 1.1  1997/03/16 04:55:59  wwg
 * Initial revision
 *
 */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdarg.h>
#include <string.h>
#include <sys/types.h>
#include <assert.h>

#include <Xm/Xm.h>
#include <Xm/Form.h>
#include <Xm/ToggleB.h>
#include <Xm/RowColumn.h>
#include <Xm/Label.h>
#include <Xm/Frame.h>

#include "xltmix.h"

static char rcsid[] = "@(#)toggle.c $Revision: 1.1 $";

static unsigned saved_outmix_sw = 0;

/*
 * This callback is used to toggle a bit in the mixer register, whenever
 * a toggle got changed.
 */
static void
ChangedToggle_CB(Widget w,XtPointer client_data,XtPointer call_data) {
	Tgl *tgl = (Tgl *)client_data;
	XmToggleButtonCallbackStruct *Ptr = (XmToggleButtonCallbackStruct *)call_data;
	unsigned b;
	unsigned bSet = (Ptr->set ? 1 : 0) ^ (tgl->bOpposite ? 1 : 0);

	tgl->bSet = Ptr->set;				/* Update our copy of setting */

	if ( tgl->mixreg >= 0 ) {
		/*
		 * This toggle represents a mixer bit:
		 */
		b = MixGetReg(tgl->mixreg);		/* Get register settings */
		if ( bSet )
			b |= (unsigned)tgl->bits;	/* Set interesting bit true */
		else	b &= ~(unsigned)tgl->bits;	/* Mask out interesting bit */
		MixPutReg(tgl->mixreg,b);		/* Now set value */
	}

	/*
	 * This special case is for toggles in the output switches
	 * group: if any of these get set, then disable the MUTE
	 * toggle (since we're suspending mute effectively)
	 */
	if ( tgl->mixreg == MIXREG_OUTMIX_SW )		/* Disable MUTE if we turn others on */
		XtVaSetValues(*pwMUTE,XmNset,False,NULL);
}

/*
 * This routine is used to take the mixer "Output Mix Switches", and to
 * set or unset the toggle visual.
 */
static void
PutToggle(Tgl *tgl,unsigned flags) {
	Boolean tf = (flags & tgl->bits) != 0 ? True : False;

	tgl->bSet = tf;
	XtVaSetValues(tgl->Toggle,XmNset,tf,NULL);
}

/*
 * This function is used to update all the Output Mix Switch toggles:
 */
static void
PutMixOUTMIX_SW(unsigned new_sw) {
	unsigned short x;
	
	for ( x=0; x<gOutput.n; ++x )
		if ( gOutput.tgl[x].mixreg != MIXREG_NONE ) /* But not the MUTE toggle itself */
			PutToggle(&gOutput.tgl[x],new_sw);  /* Update all others though */
	MixPutReg(MIXREG_OUTMIX_SW,new_sw);		/* Now put new settings into effect */
}

/*
 * This callback is made whenever the MUTE toggle is changed: When set, we save and
 * turn off all other outputs to affect a global "MUTE". If unsetting mute, then
 * we restore all saved settings.
 */
static void
ChangedMuteToggle_CB(Widget w,XtPointer client_data,XtPointer call_data) {
	Tgl *tgl = (Tgl *)client_data;
	XmToggleButtonCallbackStruct *Ptr = (XmToggleButtonCallbackStruct *)call_data;

	if ( (tgl->bSet = Ptr->set) != 0 ) {
		saved_outmix_sw = MixGetReg(MIXREG_OUTMIX_SW);
		PutMixOUTMIX_SW(0x00);			/* Global MUTE */

	} else	PutMixOUTMIX_SW(saved_outmix_sw);	/* Restore settings (and unmute) */
}

/*
 * This messy routine is used to create one toggle, which may be
 * associated with a mixer register.
 */
Widget
CreateToggle(Widget wParent,char *class_name,Tgl *tgl,TglDesc *tdesc) {
	Arg al[20];					/* Arg list */
	Cardinal ac;					/* Args count */
	char buf[80];					/* Temp edit buffer */
	Boolean bSet;					/* New value for the toggle visual */

	if ( tdesc != NULL ) {
		/*
		 * This toggle has initialization info supplied:
		 */
		tgl->mixreg = tdesc->mixreg;		/* Logical mixer register */
		tgl->bits = tdesc->bits;		/* Bit mask */
		if ( tgl->mixreg != MIXREG_NONE )
			tgl->bSet = (MixGetReg(tgl->mixreg) & (unsigned) tgl->bits) ? 1 : 0;
		else	tgl->bSet = tdesc->bits;
		tgl->bOpposite = tdesc->bOpposite;	/* AGC uses opposite logic sense */

	} else	{
		/*
		 * No mixer register, and no init. info supplied: assume defaults.
		 */
		tgl->mixreg = -1;			/* No mixer register associated */
		tgl->bits = tdesc->bits;		/* Initial setting */
		tgl->bSet = (Boolean) tdesc->bits;	/* Set to initial value */
	}

	/*
	 * Determine the visual setting: Note that AGC uses the opposite logic (bOpposite=True)
	 */
	bSet = ((tgl->bSet ? 1 : 0) ^ (tgl->bOpposite ? 1 : 0)) ? True : False;

	/*
	 * Create the toggle:
	 */
	sprintf(buf,"%s_tgl",class_name);
	ac = 0;
	XtSetArg(al[ac],XmNset,bSet); ++ac;
	tgl->Toggle = XmCreateToggleButton(wParent,buf,al,ac);
	XtManageChild(tgl->Toggle);

	/*
	 * Most toggles use callback ChangedToggle_CB(); MUTE gets its own as ChangedMuteToggle_CB()
	 */
	if ( tgl->mixreg != MIXREG_NONE )
		XtAddCallback(tgl->Toggle,XmNvalueChangedCallback,ChangedToggle_CB,(XtPointer)tgl);
	else	XtAddCallback(tgl->Toggle,XmNvalueChangedCallback,ChangedMuteToggle_CB,(XtPointer)tgl);

	return tgl->Toggle;
}

/*
 * Create a whole group of related toggle boxes:
 */
void
CreateToggleGroup(Widget wParent,char *class_name,TglGroup *pTGrp,unsigned n,TglDesc *tdesc) {
	Arg al[20];					/* Arg list */
	Cardinal ac;					/* Args count */
	char buf[80];
	int x;

	/*
	 * Container frame for these toggles:
	 */
	sprintf(buf,"%s_frame",class_name);
	ac = 0;
	XtSetArg(al[ac],XmNmarginHeight,frame_margin); ++ac;
	XtSetArg(al[ac],XmNmarginWidth,frame_margin); ++ac;
	pTGrp->Frame = XmCreateFrame(wParent,buf,al,ac);
	XtManageChild(pTGrp->Frame);

	/*
	 * The row/col container:
	 */
	sprintf(buf,"%s_rc1",class_name);
	ac = 0;
	XtSetArg(al[ac],XmNorientation,XmVERTICAL); ++ac;
	XtSetArg(al[ac],XmNpacking,XmPACK_TIGHT); ++ac;
	pTGrp->RC1 = XmCreateRowColumn(pTGrp->Frame,buf,al,ac);
	XtManageChild(pTGrp->RC1);
	
	/*
	 * Label for this grouping:
	 */
	sprintf(buf,"%s_lbl",class_name);
	ac = 0;
	pTGrp->Lbl = XmCreateLabel(pTGrp->RC1,buf,al,ac);
	XtManageChild(pTGrp->Lbl);

	/*
	 * The row/col for the toggles:
	 */
	sprintf(buf,"%s_rc2",class_name);
	ac = 0;
	XtSetArg(al[ac],XmNorientation,XmVERTICAL); ++ac;
	if ( n > 4 ) {
		XtSetArg(al[ac],XmNnumColumns,2); ++ac;
		XtSetArg(al[ac],XmNpacking,XmPACK_COLUMN); ++ac;
	}
	pTGrp->RC2 = XmCreateRowColumn(pTGrp->RC1,buf,al,ac);
	XtManageChild(pTGrp->RC2);

	pTGrp->n = n;					/* # of toggles in this group */

	/*
	 * Now create all toggles: order of creation is significant.
	 */
	for ( x=0; x<n; ++x ) {
		sprintf(buf,"%s%d",class_name,x);
		CreateToggle(pTGrp->RC2,buf,&pTGrp->tgl[x],&tdesc[x]);
	}
}

/* $Source: /wwg/motif/xltmix/RCS/toggle.c,v $ */
xltmix-1.1/xltmix-1.1.lsm100640    766    144        2560  6313060573  13453 0ustar  wwgusersBegin3
Title:		xltmix, LessTif based Mixer for SoundBlasters,
		SoundBlaster-16 and SoundBlaster-32
Version:	1.1
Entered-date:	16MAR97
Description:	At last! An X based tool that fully exploits the full
		capabilities of your SoundBlaster-16 or SoundBlaster-32
		card's mixer chip. This application uses LessTif to
		give it that cool MOTIF look and feel, and ease of use.
		Other sound cards should be supportable, if they use
		the CT1745 Mixer chip (only you know that for sure).
		The xltmix program provides all	the slider controls
		for: Voice L+R, MIDI L+R, CD L+R, Line L+R, Mic,
		and Speaker; Master controls Volume L+R, Treble L+R,
		Bass L+R; Gain controls for recording L+R and
		Mixer Gain L+R; Output toggles (CD L+R, Line L+R,
		and Mic). Also included are the input recording
		sources (MIDI L+R, CD L+R, Line L+R, and Mic).
		Additionally, a master MUTE control is provided
		for those times	when you have to take phone calls.
Keywords:	audio mix control panel CT1745 mixer SoundBlaster
Author: 	bx249@freenet.toronto.on.ca (Warren W. Gay VE3WWG)
		wwg@ica.net (Warren W. Gay VE3WWG)
Maintained-by:	bx249@freenet.toronto.on.ca (Warren W. Gay VE3WWG)
Primary-site:	sunsite.unc.edu /pub/Linux/apps/sound/
			26kB xltmix-1.1.tar.gz
			1392 xltmix-1.1.lsm
Alternate-site:
Original-site:
Platforms:	LINUX 1.2.13 or later, GCC 2.7.2, XFree86, LessTif/MOTIF
Copying-policy:	GPL
End
xltmix-1.1/xltmix.c100440    766    144       45062  6313060573  12627 0ustar  wwgusers/* $Header: /wwg/motif/xltmix/RCS/xltmix.c,v 1.1 1997/03/16 04:54:07 wwg Exp $
 * Warren W. Gay VE3WWG		Wed Mar  5 22:09:52 1997
 *
 * 	X LessTif Mix :
 * 
 * 	Copyright (C) 1997  Warren W. Gay VE3WWG
 * 
 * This  program is free software; you can redistribute it and/or modify it
 * under the  terms  of  the GNU General Public License as published by the
 * Free Software Foundation version 2 of the License.
 * 
 * This  program  is  distributed  in  the hope that it will be useful, but
 * WITHOUT   ANY   WARRANTY;   without   even  the   implied   warranty  of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 * Public License for more details (see enclosed file COPYING).
 * 
 * You  should have received a copy of the GNU General Public License along
 * with this  program; if not, write to the Free Software Foundation, Inc.,
 * 675 Mass Ave, Cambridge, MA 02139, USA.
 * 
 * Send correspondance to:
 * 
 * 	Warren W. Gay VE3WWG
 * 	5536 Montevideo Road #17
 *	Mississauga, Ontario L5N 2P4
 * 
 * Email:
 * 	wwg@ica.net			(current ISP of the month :-) )
 * 	bx249@freenet.toronto.on.ca	(backup)
 *
 * $Log: xltmix.c,v $
 * Revision 1.1  1997/03/16 04:54:07  wwg
 * Initial revision
 *
 */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdarg.h>
#include <time.h>
#include <signal.h>
#include <string.h>
#include <getopt.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <linux/soundcard.h>
#include <assert.h>

#include <Xm/Xm.h>
#include <Xm/MainW.h>
#include <Xm/Form.h>
#include <Xm/PushB.h>
#include <Xm/Text.h>
#include <Xm/Label.h>
#include <Xm/ToggleB.h>
#include <Xm/ScrollBar.h>
#include <Xm/RowColumn.h>
#include <Xm/Frame.h>
#include <Xm/MessageB.h>

#include "xltmix.h"

static char *rcsid[] = { "@(#)xltmix.c $Revision: 1.1 $", _xltmix_h_ };

char vers[] = "$Revision: 1.1 $";			/* This gets edited at startup */
int frame_margin = 6;				/* Use 6 pixels for a margin */

/*
 * Damage Control:
 */
Boolean bFatal = 0;				/* True if fatal error hit */
Boolean bPortAccessFailed = False;		/* Set by MixInit() if ports cannot be accessed */
Boolean bPortInvalid = False;			/* Set by MixInit() if port is bad */
char fatalMsg[512];				/* Fatal message text is put here */

/*
 * FALLBACK RESOURCES :
 */
static String fallback_resources[] = {
	"XLTMix.geometry: +250+200",
	"XLTMix*background: grey75",
	"XLTMix.*fontList: *helvetica-bold-r-normal--14*",

	"XLTMix.main.menubar.spacing: 10",
	"XLTMix.main.menubar.filemenucascade.labelString: File",
	"XLTMix*filemenu.exit.labelString: Exit",
	"XLTMix.main.menubar.helpmenucascade.labelString: Help",
	"XLTMix*helpmenu.about.labelString: About",

	"XLTMix*AboutDlg.fontList: -adobe-helvetica-medium-r-normal-*-10-100-75-75-p-*-iso8859-1",

	"XLTMix*dev_lbl.labelString: Input Levels",
	"XLTMix*dev_lbl.fontList: *helvetica-bold-r-normal--12*",

	"XLTMix*dev_rc1*fontList: *helvetica-bold-r-normal--8*",
	"XLTMix*ctlvoc_lbl.labelString: Voice",
	"XLTMix*ctlmidi_lbl.labelString: MIDI",
	"XLTMix*ctlcd_lbl.labelString: CD",
	"XLTMix*ctlline_lbl.labelString: Line",
	"XLTMix*ctlmic_lbl.labelString: Mic",
	"XLTMix*ctlspk_lbl.labelString: Spk",

	"XLTMix*gain_lbl.labelString: Gain Levels",
	"XLTMix*gain_lbl.fontList: *helvetica-bold-r-normal--12*",

	"XLTMix*gain_rc1*fontList: *helvetica-bold-r-normal--8*",
	"XLTMix*igain_lbl.labelString: Rec. Gain",
	"XLTMix*ogain_lbl.labelString: Mixer Gain",

	"XLTMix*mctl_lbl.labelString: Master Levels",
	"XLTMix*mctl_lbl.fontList: *helvetica-bold-r-normal--12*",

	"XLTMix*mctl_rc1*fontList: *helvetica-bold-r-normal--8*",
	"XLTMix*vol_lbl.labelString: Volume",
	"XLTMix*treble_lbl.labelString: Treble",
	"XLTMix*bass_lbl.labelString: Bass",

	"XLTMix*inpLeft_lbl.labelString: Left Record Inputs:",
	"XLTMix*inpLeft_lbl.fontList: *helvetica-bold-r-normal--12*",
	"XLTMix*inpLeft_rc2*fontList: *helvetica-bold-r-normal--10*",
	"XLTMix*inpLeft0_tgl.labelString: MIDI Left",
	"XLTMix*inpLeft1_tgl.labelString: Line Left",
	"XLTMix*inpLeft2_tgl.labelString: CD Left",
	"XLTMix*inpLeft3_tgl.labelString: Microphone",
	"XLTMix*inpLeft4_tgl.labelString: MIDI Right",
	"XLTMix*inpLeft5_tgl.labelString: Line Right",
	"XLTMix*inpLeft6_tgl.labelString: CD Right",

	"XLTMix*inpRight_lbl.labelString: Right Record Inputs:",
	"XLTMix*inpRight_lbl.fontList: *helvetica-bold-r-normal--12*",
	"XLTMix*inpRight_rc2*fontList: *helvetica-bold-r-normal--10*",
	"XLTMix*inpRight0_tgl.labelString: MIDI Left",
	"XLTMix*inpRight1_tgl.labelString: Line Left",
	"XLTMix*inpRight2_tgl.labelString: CD Left",
	"XLTMix*inpRight3_tgl.labelString: Microphone",
	"XLTMix*inpRight4_tgl.labelString: MIDI Right",
	"XLTMix*inpRight5_tgl.labelString: Line Right",
	"XLTMix*inpRight6_tgl.labelString: CD Right",

	"XLTMix*controls_lbl.labelString: Mixer Controls:",
	"XLTMix*controls_lbl.fontList: *helvetica-bold-r-normal--12*",
	"XLTMix*controls_rc2*fontList: *helvetica-bold-r-normal--10*",
	"XLTMix*controls0_tgl.labelString: AGC",

	"XLTMix*output_lbl.labelString: Mixer Outputs:",
	"XLTMix*output_lbl.fontList: *helvetica-bold-r-normal--12*",
	"XLTMix*output_rc2*fontList: *helvetica-bold-r-normal--10*",
	"XLTMix*output0_tgl.labelString: Line Left",
	"XLTMix*output1_tgl.labelString: CD Left",
	"XLTMix*output2_tgl.labelString: Microphone",
	"XLTMix*output3_tgl.labelString: Line Right",
	"XLTMix*output4_tgl.labelString: CD Right",
	"XLTMix*output5_tgl.labelString: MUTE",

	NULL
};

/*
 * WIDGETS :
 */
Widget wParent;						/* Parent shell widget */
XtAppContext aContext;					/* Application context */

Widget wMain;						/* Main widget */
Widget wMain_RC1;
Widget wMain_RC2;
Widget wMenuBar;					/* Main menu bar */
Widget wFileMenuCascade;				/* Cascade button for File Menu */
Widget wFileMenu;					/* File menu itself */
Widget wExit;						/* File->Exit */

Widget wHelpMenuCascade;				/* Cascade button for Help Menu */
Widget wHelpMenu;					/* Help menu itself */
Widget wAbout;						/* Help->About */

Widget wErrDlg;						/* Error Dialog Box */
XmString sErrDlgTitle;					/* Title for the Error Dialog Box */

Widget wAboutDlg;					/* About Dialog Box */
XmString sAboutDlgTitle;				/* About Dialog Title String */
XmString sAboutDlgMessage;				/* About Dialog message and copyright */

Widget wDevFrame;					/* Frame about device controls */
Widget wDevFrame_Lbl;					/* Label for this Frame */
Widget wDevFrame_RC0;					/* Vertical RC */
Widget wDevFrame_RC1;					/* Horizontal RC */
DevSliders devVoice;					/* Digitized voice */
DevSliders devMIDI;					/* MIDI device */
DevSliders devCD;					/* CD Audio */
DevSliders devLine;					/* Line in jack */
Widget wMicSpk_RC;
DevSliders devMic;					/* Microphone */
DevSliders devSpk;					/* PC Speaker */

Widget wGainFrame;					/* Gain controls */
Widget wGainFrame_Lbl;
Widget wGainFrame_RC0;					/* Holds wGainFrame_Lbl + wGainFrame_RC1 */
Widget wGainFrame_RC1;					/* Gain controls: Row column */
DevSliders inpGain;					/* Input Gain: Left + Right */
DevSliders outGain;					/* Output Gain: Left + Right */

Widget wMctlFrame;					/* Master controls */
Widget wMctlFrame_Lbl;
Widget wMctlFrame_RC0;					/* Holds a label + RC1 */
Widget wMctlFrame_RC1;					/* Master controls: Row column */
DevSliders mctlVol;					/* Volume left + right */
DevSliders mctlTreble;					/* Treble left + right */
DevSliders mctlBass;					/* Bass left + right */

Widget wTgl_RC;						/* Toggles row across bottom */
TglGroup gInpLeft;					/* Input Left switches */
TglGroup gInpRight;					/* Input Right switches */
TglGroup gControls;					/* Controls Group */
TglGroup gOutput;					/* Output switches */
Widget *pwMUTE = &gOutput.tgl[5].Toggle;		/* Point to MUTE widget */

/*
 * Initialization Lists:
 */
static TglDesc bInpLeftSet[8] = {
	{ MIXREG_INMIX_SW_L, 0x40, False },		/* MIDI-L */
	{ MIXREG_INMIX_SW_L, 0x10, False },		/* Line-L */
	{ MIXREG_INMIX_SW_L, 0x04, False },		/* CD-L */
	{ MIXREG_INMIX_SW_L, 0x01, False },		/* Mic */
	{ MIXREG_INMIX_SW_L, 0x20, False },		/* MIDI-R */
	{ MIXREG_INMIX_SW_L, 0x08, False },		/* Line-R */
	{ MIXREG_INMIX_SW_L, 0x02, False },		/* CD-R */
	{ MIXREG_AGC,        0x01, False },		/* AGC */
};
static TglDesc bInpRightSet[7] = {
	{ MIXREG_INMIX_SW_R, 0x40, False },		/* MIDI-L */
	{ MIXREG_INMIX_SW_R, 0x10, False },		/* Line-L */
	{ MIXREG_INMIX_SW_R, 0x04, False },		/* CD-L */
	{ MIXREG_INMIX_SW_R, 0x01, False },		/* Mic */
	{ MIXREG_INMIX_SW_R, 0x20, False },		/* MIDI-R */
	{ MIXREG_INMIX_SW_R, 0x08, False },		/* Line-R */
	{ MIXREG_INMIX_SW_R, 0x02, False },		/* CD-R */
};
static TglDesc bControlsSet[1] = {
	{ MIXREG_AGC,        0x01, True },		/* AGC */
};
static TglDesc bOutSet[6] = {
	{ MIXREG_OUTMIX_SW, 0x10, False },		/* Line-L */
	{ MIXREG_OUTMIX_SW, 0x04, False },		/* CD-L */
	{ MIXREG_OUTMIX_SW, 0x01, False },		/* Mic */
	{ MIXREG_OUTMIX_SW, 0x08, False },		/* Line-R */
	{ MIXREG_OUTMIX_SW, 0x02, False },		/* CD-R */
	{ MIXREG_NONE,      0x00, False },		/* MUTE (not a mixer function) */
};

/*
 * The infamous "main" program:
 */
int
main(int argc,char **argv) {
	Arg al[20];					/* Arg list */
	Cardinal ac;					/* Args count */
	
	/*
	 * Do mixer initialization:
	 */
	MixInit();

	/*
	 * When this program runs as setuid 'root', we want to switch back to ourself
	 * as soon as possible. We do that here, since after we have access from the
	 * MixInit() call, we can be ourselves again.
	 */
	setuid(getuid());

	/*
	 * Do some text editing on the RCS Id strings for display purposes:
	 */
	EditVersionInit();				/* Edit $ Revision $ string into vers[] */
	{
		char edited_title[1024];

		EditVersion("X LessTif Mix Version $",edited_title);

		/*
		 * CreateApplication Context:
		 */
		ac = 0;
		XtSetArg(al[ac],XmNtitle,edited_title); ++ac;
		wParent = XtAppInitialize(&aContext,
			"XLTMix",			/* app. class */
			(XrmOptionDescList) NULL, 0,	/* options */
			&argc, argv,			/* cmd line */
			fallback_resources,		/* fallback resources */
			al,ac);				/* hard coded resources */
	}

	/*
	 * Create Main widget:
	 */
	ac = 0;
	wMain = XmCreateMainWindow(wParent,"main",al,ac);
	XtManageChild(wMain);				/* Main window widget */

	/*
	 * Create the Menu Bar:
	 */
	ac = 0;
	wMenuBar = XmCreateMenuBar(wMain,"menubar",al,ac);
	XtManageChild(wMenuBar);			/* Main window menu bar */

	CreateMenu(wMenuBar,&wFileMenu,"filemenu",&wFileMenuCascade,"filemenucascade",
		"exit",'M',ExitCB,&wExit,
		NULL);

	CreateMenu(wMenuBar,&wHelpMenu,"helpmenu",&wHelpMenuCascade,"helpmenucascade",
		"about",'M',AboutCB,&wAbout,
		NULL);

	XtManageChild(wFileMenuCascade);			/* File Menu cascade button */
	XtManageChild(wExit);					/* File->Exit */
	XtManageChild(wHelpMenuCascade);			/* Help menu cascade bytton */

	/*
	 * main_rc1 is the vertical Row/Col manager for the main window:
	 */
	ac = 0;
	XtSetArg(al[ac],XmNorientation,XmVERTICAL); ++ac;
	XtSetArg(al[ac],XmNpacking,XmPACK_TIGHT); ++ac;
	wMain_RC1 = XmCreateRowColumn(wMain,"main_rc1",al,ac);
	XtManageChild(wMain_RC1);				/* Main window widget */

	/*
	 * main_rc2 is the horizontal top row Row/Col manager for the
	 * scroll bar controls.
	 */
	ac = 0;
	XtSetArg(al[ac],XmNorientation,XmHORIZONTAL); ++ac;
	XtSetArg(al[ac],XmNpacking,XmPACK_TIGHT); ++ac;
	wMain_RC2 = XmCreateRowColumn(wMain_RC1,"main_rc2",al,ac);
	XtManageChild(wMain_RC2);				/* Main window widget */

	/*
	 * Create the error message dialog:
	 */
	sErrDlgTitle = XmStringCreate("X LessTif Mix : Error Message",XmSTRING_DEFAULT_CHARSET);
	ac = 0;
	XtSetArg(al[ac],XmNdialogStyle,XmDIALOG_APPLICATION_MODAL); ac++;
	XtSetArg(al[ac],XmNtitle,"Error Report"); ac++;
	XtSetArg(al[ac],XmNdefaultButtonType,XmDIALOG_OK_BUTTON); ++ac;
	XtSetArg(al[ac],XmNmessageAlignment,XmALIGNMENT_CENTER); ++ac;
	XtSetArg(al[ac],XmNdialogTitle,sErrDlgTitle); ++ac;
	XtSetArg(al[ac],XmNallowResize,False); ++ac;
	wErrDlg = XmCreateErrorDialog(wParent,"ErrDlg",al,ac);
	XtAddCallback(wErrDlg,XmNokCallback,ExitDlgCB,NULL);
	XtUnmanageChild(XmMessageBoxGetChild(wErrDlg,XmDIALOG_CANCEL_BUTTON));
	XtUnmanageChild(XmMessageBoxGetChild(wErrDlg,XmDIALOG_HELP_BUTTON));

	/*
	 * Create About Dialog Title and Message strings:
	 */
	sAboutDlgTitle = XmStringCreate("X LessTif Mix : Help->About",XmSTRING_DEFAULT_CHARSET);
	{
		char buf[1024];

		EditVersion(
			"X LessTif Mix Version $\n"
			"was written by and is\n"
			"Copyright (C) 1997 by Warren W. Gay VE3WWG\n"
			"---\n"
			"Many thanks to the LINUX folks,\n"
			"the XFree86 folks,\n"
			"and of course the LessTif group\n"
			"for making this application possible.\n"
			"---\n"
			"This program comes with\n"
			"ABSOLUTELY NO WARRANTY.",
			buf);

		sAboutDlgMessage = XmStringCreateLtoR(buf,XmSTRING_DEFAULT_CHARSET);
	}
		
	/*
	 * Create About Dialog Box itself:
	 */
	ac = 0;
	XtSetArg(al[ac],XmNdefaultPosition,False); ac++;
	XtSetArg(al[ac],XmNtitle,"Error Report"); ac++;
	XtSetArg(al[ac],XmNdefaultButtonType,XmDIALOG_OK_BUTTON); ++ac;
	XtSetArg(al[ac],XmNmessageAlignment,XmALIGNMENT_CENTER); ++ac;
	XtSetArg(al[ac],XmNdialogTitle,sAboutDlgTitle); ++ac;
	XtSetArg(al[ac],XmNallowResize,False); ++ac;
	wAboutDlg = XmCreateMessageDialog(wParent,"AboutDlg",al,ac);
	XtAddCallback(wAboutDlg,XmNokCallback,AboutDlgOkCB,NULL);
	XtUnmanageChild(XmMessageBoxGetChild(wAboutDlg,XmDIALOG_CANCEL_BUTTON));
	XtUnmanageChild(XmMessageBoxGetChild(wAboutDlg,XmDIALOG_HELP_BUTTON));
	XtManageChild(wAbout);					/* Help->About */

	/*
	 * Now if the mixer did not initialize successfully, we must put up the
	 * error dialog now, and then bail out.
	 */
	if ( bPortAccessFailed || bPortInvalid ) {
		bFatal = True;
		ReportError(__FILE__,__LINE__,"%s",fatalMsg);
		XtRealizeWidget(wParent);			/* OK, realize it all.. */
		XtAppMainLoop(aContext);
		exit(1);					/* Should never get here */
	}

	/*
	 * Device Frame (Input Levels):
	 */
	ac = 0;
	XtSetArg(al[ac],XmNmarginHeight,frame_margin); ++ac;
	XtSetArg(al[ac],XmNmarginWidth,frame_margin); ++ac;
	wDevFrame = XmCreateFrame(wMain_RC2,"dev_frame",al,ac);
	XtManageChild(wDevFrame);

	/*
	 * dev_rc0 holds the "Input Level" label + the scroll bars beneath
	 */
	ac = 0;
	XtSetArg(al[ac],XmNorientation,XmVERTICAL); ++ac;
	XtSetArg(al[ac],XmNpacking,XmPACK_TIGHT); ++ac;
	wDevFrame_RC0 = XmCreateRowColumn(wDevFrame,"dev_rc0",al,ac);
	XtManageChild(wDevFrame_RC0);

	/*
	 * Label "Input Levels"
	 */
	ac = 0;
	wDevFrame_Lbl = XmCreateLabel(wDevFrame_RC0,"dev_lbl",al,ac);
	XtManageChild(wDevFrame_Lbl);

	/*
	 * dev_rc1 holds the various controls horizontally
	 */
	ac = 0;
	XtSetArg(al[ac],XmNorientation,XmHORIZONTAL); ++ac;
	XtSetArg(al[ac],XmNpacking,XmPACK_TIGHT); ++ac;
	wDevFrame_RC1 = XmCreateRowColumn(wDevFrame_RC0,"dev_rc1",al,ac);
	XtManageChild(wDevFrame_RC1);

	/*
	 * Create the input level controls:
	 */
	CreateSliders(wDevFrame_RC1,"ctlvoc",&devVoice,1,31,MIXREG_VOICE_L5,MIXREG_VOICE_R5);
	CreateSliders(wDevFrame_RC1,"ctlmidi",&devMIDI,1,31,MIXREG_MIDI_L5,MIXREG_MIDI_R5);
	CreateSliders(wDevFrame_RC1,"ctlcd",&devCD,1,31,MIXREG_CD_L5,MIXREG_CD_R5);
	CreateSliders(wDevFrame_RC1,"ctlline",&devLine,1,31,MIXREG_LINE_L5,MIXREG_LINE_R5);

	/*
	 * Container for the Mic and Spk level controls:
	 */
	ac = 0;
	XtSetArg(al[ac],XmNorientation,XmHORIZONTAL); ++ac;
	XtSetArg(al[ac],XmNpacking,XmPACK_COLUMN); ++ac;
	XtSetArg(al[ac],XmNmarginHeight,0); ++ac;
	XtSetArg(al[ac],XmNmarginWidth,0); ++ac;
	wMicSpk_RC = XmCreateRowColumn(wDevFrame_RC1,"micspk_rc",al,ac);
	XtManageChild(wMicSpk_RC);

	/*
	 * Create the Mic and Spkr level controls:
	 */
	CreateSliders(wMicSpk_RC,"ctlmic",&devMic,0,31,MIXREG_MIC_5,MIXREG_NONE);
	CreateSliders(wMicSpk_RC,"ctlspk",&devSpk,0,3,MIXREG_SPKR_2,MIXREG_NONE);

	/*
	 * Gain Control Frame:
	 */
	ac = 0;
	XtSetArg(al[ac],XmNmarginHeight,frame_margin); ++ac;
	XtSetArg(al[ac],XmNmarginWidth,frame_margin); ++ac;
	wGainFrame = XmCreateFrame(wMain_RC2,"gain_frame",al,ac);
	XtManageChild(wGainFrame);

	/*
	 * gain_rc0 holds the "Mixer Gain" label + controls (vertical)
	 */
	ac = 0;
	XtSetArg(al[ac],XmNorientation,XmVERTICAL); ++ac;
	XtSetArg(al[ac],XmNpacking,XmPACK_TIGHT); ++ac;
	wGainFrame_RC0 = XmCreateRowColumn(wGainFrame,"gain_rc0",al,ac);
	XtManageChild(wGainFrame_RC0);

	/*
	 * "Mixer Gain" Label:
	 */
	ac = 0;
	wGainFrame_Lbl = XmCreateLabel(wGainFrame_RC0,"gain_lbl",al,ac);
	XtManageChild(wGainFrame_Lbl);

	/*
	 * gain_rc1 holds the Mixer Gain controls horizontally:
	 */
	ac = 0;
	XtSetArg(al[ac],XmNorientation,XmHORIZONTAL); ++ac;
	XtSetArg(al[ac],XmNpacking,XmPACK_TIGHT); ++ac;
	wGainFrame_RC1 = XmCreateRowColumn(wGainFrame_RC0,"gain_rc1",al,ac);
	XtManageChild(wGainFrame_RC1);

	/*
	 * Create input and output gain level controls:
	 */
	CreateSliders(wGainFrame_RC1,"igain",&inpGain,1,3,MIXREG_IGAIN_L2,MIXREG_IGAIN_R2);
	CreateSliders(wGainFrame_RC1,"ogain",&outGain,1,3,MIXREG_OGAIN_L2,MIXREG_OGAIN_R2);

	/*
	 * Master Control Frame (Master Levels):
	 */
	ac = 0;
	XtSetArg(al[ac],XmNmarginHeight,frame_margin); ++ac;
	XtSetArg(al[ac],XmNmarginWidth,frame_margin); ++ac;
	wMctlFrame = XmCreateFrame(wMain_RC2,"mctl_frame",al,ac);
	XtManageChild(wMctlFrame);

	/*
	 * mctl_rc0 holds the label + controls (vertically)
	 */
	ac = 0;
	XtSetArg(al[ac],XmNorientation,XmVERTICAL); ++ac;
	XtSetArg(al[ac],XmNpacking,XmPACK_TIGHT); ++ac;
	wMctlFrame_RC0 = XmCreateRowColumn(wMctlFrame,"mctl_rc0",al,ac);
	XtManageChild(wMctlFrame_RC0);

	/*
	 * "Master Levels" Label:
	 */
	ac = 0;
	wMctlFrame_Lbl = XmCreateLabel(wMctlFrame_RC0,"mctl_lbl",al,ac);
	XtManageChild(wMctlFrame_Lbl);

	/*
	 * mctl_rc1 holds the master level controls horizontally
	 */
	ac = 0;
	XtSetArg(al[ac],XmNorientation,XmHORIZONTAL); ++ac;
	XtSetArg(al[ac],XmNpacking,XmPACK_TIGHT); ++ac;
	wMctlFrame_RC1 = XmCreateRowColumn(wMctlFrame_RC0,"mctl_rc1",al,ac);
	XtManageChild(wMctlFrame_RC1);

	/*
	 * Create Master Level controls for volume, treble and bass
	 */
	CreateSliders(wMctlFrame_RC1,"vol",&mctlVol,1,31,MIXREG_MSTR_L5,MIXREG_MSTR_R5);
	CreateSliders(wMctlFrame_RC1,"treble",&mctlTreble,1,15,MIXREG_TREBLE_L4,MIXREG_TREBLE_R4);
	CreateSliders(wMctlFrame_RC1,"bass",&mctlBass,1,15,MIXREG_BASS_L4,MIXREG_BASS_R4);

	/*
	 * tgl_rc holds the groups of toggles horizontally:
	 */
	ac = 0;
	XtSetArg(al[ac],XmNorientation,XmHORIZONTAL); ++ac;
	XtSetArg(al[ac],XmNpacking,XmPACK_TIGHT); ++ac;
	XtSetArg(al[ac],XmNisAligned,False); ++ac;
	wTgl_RC = XmCreateRowColumn(wMain_RC1,"tgl_rc",al,ac);
	XtManageChild(wTgl_RC);

	/*
	 * Create toggle groups:	Record Left and Right Record Inputs,
	 *				Mixer Controls, and
	 *				Mixer Outputs
	 */
	CreateToggleGroup(wTgl_RC,"inpLeft",&gInpLeft,7,bInpLeftSet);
	CreateToggleGroup(wTgl_RC,"inpRight",&gInpRight,7,bInpRightSet);
	CreateToggleGroup(wTgl_RC,"controls",&gControls,1,bControlsSet);
	CreateToggleGroup(wTgl_RC,"output",&gOutput,6,bOutSet);

	/*
	 * The MOTIF Main Loop:
	 */
	XtRealizeWidget(wParent);				/* OK, realize it all.. */
	XtAppMainLoop(aContext);
	return 0;						/* A cookie for the compiler */
}                       

/* $Source: /wwg/motif/xltmix/RCS/xltmix.c,v $ */

xltmix-1.1/xltmix.h100440    766    144       16014  6313060573  12627 0ustar  wwgusers/* $Header: /wwg/motif/xltmix/RCS/xltmix.h,v 1.1 1997/03/16 04:52:35 wwg Exp $
 * Warren W. Gay VE3WWG		Wed Mar  5 22:19:37 1997
 *
 * 	X LessTif Mix :
 * 
 * 	Copyright (C) 1997  Warren W. Gay VE3WWG
 * 
 * This  program is free software; you can redistribute it and/or modify it
 * under the  terms  of  the GNU General Public License as published by the
 * Free Software Foundation version 2 of the License.
 * 
 * This  program  is  distributed  in  the hope that it will be useful, but
 * WITHOUT   ANY   WARRANTY;   without   even  the   implied   warranty  of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 * Public License for more details (see enclosed file COPYING).
 * 
 * You  should have received a copy of the GNU General Public License along
 * with this  program; if not, write to the Free Software Foundation, Inc.,
 * 675 Mass Ave, Cambridge, MA 02139, USA.
 * 
 * Send correspondance to:
 * 
 * 	Warren W. Gay VE3WWG
 * 	5536 Montevideo Road #17
 *	Mississauga, Ontario L5N 2P4
 * 
 * Email:
 * 	wwg@ica.net			(current ISP of the month :-) )
 * 	bx249@freenet.toronto.on.ca	(backup)
 *
 * $Log: xltmix.h,v $
 * Revision 1.1  1997/03/16 04:52:35  wwg
 * Initial revision
 *
 */
#ifndef _xltmix_h_
#define _xltmix_h_ "@(#)xltmix.h $Revision: 1.1 $"

#ifndef DEV_BASE
#define DEV_BASE	0x220U				/* Base port address */
#endif

#define DEV_INDX	(DEV_BASE+4U)			/* Mixer "index" port */
#define DEV_DATA	(DEV_BASE+5U)			/* Mixer "data" port */

/*
 * This structure describes a single, or pair of scrollbars used as sliding
 * mixer controls.
 */
typedef struct {
	Widget	Frame;					/* Enclosing Frame */
	Widget	RC;					/* Row/Column for label and scroll bar */
	Widget	Lbl;					/* Label widget */
	Widget	RC2;					/* Left + Right RowColumn */
	Widget	Left;					/* Left scroll bar */
	Widget	Right;					/* Right scroll bar */
	int	vLeft;					/* Current value of the left slider */
	int	vRight;					/* Current value of the right slider */
	int	max;					/* Maximum value for these slider(s) */
	unsigned xL;					/* Left logical register index */
	unsigned xR;					/* Right logical register index */
} DevSliders;

/*
 * This structure describes one toggle, its current value and
 * associated mixer register if any.
 */
typedef struct {
	Widget	Toggle;					/* The Toggle itself */
	Boolean	bSet;					/* Its current setting */
	short	mixreg;					/* -1, or logical mixer register */
	char	bits;					/* Bit pattern if reg != -1 */
	Boolean	bOpposite;				/* When True, use opposite logic sense */
} Tgl;

/*
 * This toggle description structure is used by initialization
 * and creation of the toggles only.
 */
typedef struct {
	int	mixreg;					/* Mixer register (logical) */
	char	bits;					/* Bit pattern */
	Boolean	bOpposite;				/* When True, use opposite logic sense */
} TglDesc;

/*
 * This structure describes a group of toggles.
 */
typedef struct {
	Widget	Frame;					/* Toggle group's frame */
	Widget	RC1;					/* Toggle group's outter Row/Col */
	Widget	RC2;					/* Toggle group's inner Row/Col */
	Widget	Lbl;					/* Group label */
	int	n;					/* Number of toggles */
	Tgl	tgl[8];					/* Max 8 toggles */
} TglGroup;

/*
 * External Callbacks:
 */
extern void AboutDlgOkCB(Widget w,XtPointer client_data,XtPointer call_data);
extern void AboutCB(Widget w,XtPointer client_data,XtPointer call_data);
extern void ExitCB(Widget w,XtPointer client_data,XtPointer call_data);
extern void ExitDlgCB(Widget w,XtPointer client_data,XtPointer call_data);

/*
 * External routines:
 */
extern int MixInit(void);
extern void MixerClose(void);
extern unsigned MixGetReg(unsigned reg);
extern void MixPutReg(unsigned reg,unsigned b);
extern void EditVersionInit(void);
extern char *EditVersion(char *pString,char *pBuffer);
extern void CreateMenu(Widget wMenuBar,Widget *wPulldown,char *namePulldown,Widget *wCascade,char *nameCascade,...);
extern Widget CreateToggle(Widget wParent,char *class_name,Tgl *tgl,TglDesc *tdesc);
extern void CreateToggleGroup(Widget wParent,char *class_name,TglGroup *pTGrp,unsigned n,TglDesc *tdesc);
extern Widget CreateSliders(Widget parent,char *class,DevSliders *pSliders,short bStereo,int max,unsigned xL,unsigned xR);
extern void ReportError(const char *file,unsigned lno,const char *format,...);

/*
 * These are the definitions of the _LOGICAL_ mixer registers. The physical
 * groups of mixer registers are considerably fewer.
 */
#define MIXREG_RESET		0
#define MIXREG_NONE		(MIXREG_RESET)
	/*
	 * This group of compatibility registers are not used by this program
	 * because of their lower resolution (4 bits)
	 */
#define MIXREG_VOICE_L4		1
#define MIXREG_VOICE_R4		2
#define MIXREG_MIC_4		3
#define MIXREG_MSTR_L4		4
#define MIXREG_MSTR_R4		5
#define MIXREG_MIDI_L4		6
#define MIXREG_MIDI_R4		7
#define MIXREG_CD_L4		8
#define MIXREG_CD_R4		9
#define MIXREG_LINE_L4		10
#define MIXREG_LINE_R4		11
	/*
	 * These are the preferred registers for SB16 and SB32, since the volume
	 * settings have 5 bits.
	 */
#define MIXREG_MSTR_L5		12
#define MIXREG_MSTR_R5		13
#define MIXREG_VOICE_L5		14
#define MIXREG_VOICE_R5		15
#define MIXREG_MIDI_L5		16
#define MIXREG_MIDI_R5		17
#define MIXREG_CD_L5		18
#define MIXREG_CD_R5		19
#define MIXREG_LINE_L5		20
#define MIXREG_LINE_R5		21
#define MIXREG_MIC_5		22
#define MIXREG_SPKR_2		23
#define MIXREG_OUTMIX_SW	24
#define MIXREG_INMIX_SW_L	25
#define MIXREG_INMIX_SW_R	26
#define MIXREG_IGAIN_L2		27
#define MIXREG_IGAIN_R2		28
#define MIXREG_OGAIN_L2		29
#define MIXREG_OGAIN_R2		30
#define MIXREG_AGC		31
#define MIXREG_TREBLE_L4	32
#define MIXREG_TREBLE_R4	33
#define MIXREG_BASS_L4		34
#define MIXREG_BASS_R4		35

/*
 * xltmix.c externals
 */
extern char vers[];
extern int frame_margin;

extern Boolean bFatal;
extern Boolean bPortAccessFailed;
extern Boolean bPortInvalid;
extern char fatalMsg[];

extern Widget wParent;
extern XtAppContext aContext;

extern Widget wMain;
extern Widget wMain_RC1;
extern Widget wMain_RC2;
extern Widget wMenuBar;
extern Widget wFileMenuCascade;
extern Widget wFileMenu;
extern Widget wExit;

extern Widget wHelpMenuCascade;
extern Widget wHelpMenu;
extern Widget wAbout;

extern Widget wErrDlg;
extern XmString sErrDlgTitle;

extern Widget wAboutDlg;
extern XmString sAboutDlgTitle;
extern XmString sAboutDlgMessage;

extern Widget wDevFrame;
extern Widget wDevFrame_Lbl;
extern Widget wDevFrame_RC0;
extern Widget wDevFrame_RC1;
extern DevSliders devVoice;
extern DevSliders devMIDI;
extern DevSliders devCD;
extern DevSliders devLine;
extern Widget wMicSpk_RC;
extern DevSliders devMic;
extern DevSliders devSpk;

extern Widget wGainFrame;
extern Widget wGainFrame_Lbl;
extern Widget wGainFrame_RC0;
extern Widget wGainFrame_RC1;
extern DevSliders inpGain;
extern DevSliders outGain;

extern Widget wMctlFrame;
extern Widget wMctlFrame_Lbl;
extern Widget wMctlFrame_RC0;
extern Widget wMctlFrame_RC1;
extern DevSliders mctlVol;
extern DevSliders mctlTreble;
extern DevSliders mctlBass;

extern Widget wTgl_RC;
extern TglGroup gInpLeft;
extern TglGroup gInpRight;
extern TglGroup gControls;
extern TglGroup gOutput;
extern Widget *pwMUTE;

#endif /* _xltmix_h_ */

/* $Source: /wwg/motif/xltmix/RCS/xltmix.h,v $ */
xltmix-1.1/xmsprint.c100440    766    144        3636  6313060573  13147 0ustar  wwgusers/* $Header: /wwg/motif/xltmix/RCS/xmsprint.c,v 1.1 1997/03/16 04:56:06 wwg Exp $
 * Warren W. Gay VE3WWG		Sat Mar  1 14:04:46 1997
 *
 * Format a string: XmString XmSprintf(format,...)
 *
 * $Log: xmsprint.c,v $
 * Revision 1.1  1997/03/16 04:56:06  wwg
 * Initial revision
 *
 */
static char rcsid[] = "@(#)xmsprint.c $Revision: 1.1 $";

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdarg.h>
#include <string.h>
#include <time.h>
#include <Xm/Xm.h>
#include <Xm/Text.h>
#include "xmsprint.h"

/*
 * Create a XmString using the conveniance of a printf() styled call:
 */
XmString
XmSprintf(const char *format,...) {
	char buf[2048];
	va_list ap;

	/*
	 * First format the message:
	 */
	va_start(ap,format);
	vsprintf(buf,format,ap);
	va_end(ap);
	
	/*
	 * Now create the XmString to return:
	 */
	return XmStringCreateLtoR(buf,XmSTRING_DEFAULT_CHARSET);
}

/*
 * sprintf into a label widget:
 */
void
XmSprintfLabel(Widget w,const char *format,...) {
	char buf[2048];
	va_list ap;
	XmString s;

	/*
	 * First format the message:
	 */
	va_start(ap,format);
	vsprintf(buf,format,ap);
	va_end(ap);
	
	/*
	 * Now create the XmString to return:
	 */
	s = XmStringCreateLtoR(buf,XmSTRING_DEFAULT_CHARSET);
	XtVaSetValues(w,XmNlabelString,s,NULL);
	XmStringFree(s);
}

/*
 * printf into a text widget:
 */
void
XmSprintfText(Widget w,const char *format,...) {
	char buf[2048];
	va_list ap;

	/*
	 * First format the message:
	 */
	va_start(ap,format);
	vsprintf(buf,format,ap);
	va_end(ap);
	
	XmTextSetString(w,buf);					/* Set text in widget now */
	XmTextSetInsertionPosition(w,0);			/* Put cursor at start of field */
}

/*
 * Return an ascii string date, without the newline:
 */
char *
StrDate(time_t td) {
	char *cp;
	static char stbuf[64];

	strcpy(stbuf,ctime(&td));
	if ( (cp = strchr(stbuf,'\n')) != NULL )
		*cp = 0;					/* Stomp on the newline */	
	return stbuf;
}

/* $Source: /wwg/motif/xltmix/RCS/xmsprint.c,v $ */
xltmix-1.1/xmsprint.h100440    766    144        1153  6313060573  13144 0ustar  wwgusers/* $Header: /wwg/motif/xltmix/RCS/xmsprint.h,v 1.1 1997/03/16 04:53:04 wwg Exp $
 * Warren W. Gay VE3WWG		Sat Mar  1 14:10:02 1997
 *
 * XmSprintf header file:
 *
 * $Log: xmsprint.h,v $
 * Revision 1.1  1997/03/16 04:53:04  wwg
 * Initial revision
 *
 */
#ifndef _xmsprint_h_
#define _xmsprint_h_ "@(#)xmsprint.h $Revision: 1.1 $"

extern XmString XmSprintf(const char *format,...);
extern void XmSprintfLabel(Widget w,const char *format,...);
extern void XmSprintfText(Widget w,const char *format,...);

extern char *StrDate(time_t td);

#endif /* _xmsprint_h_ */

/* $Source: /wwg/motif/xltmix/RCS/xmsprint.h,v $ */
Results 1 - 1
Help - FTP Sites List - Software Dir.
Searching half a billion files worldwide
© 1997-2008 IT MARUHN