More pruning of the rsynth codebase.

Added stubs for 4A50 bankswitching scheme.  Autodetection of this cartridge
isn't working, and the actual class doesn't do anything!  But it's a start.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1115 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2006-06-12 14:12:52 +00:00
parent 66861f2f95
commit e55f4258b8
34 changed files with 281 additions and 4162 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Cart.cxx,v 1.19 2006-03-05 01:18:41 stephena Exp $
// $Id: Cart.cxx,v 1.20 2006-06-12 14:12:51 stephena Exp $
//============================================================================
#include <assert.h>
@ -23,6 +23,7 @@
#include "Cart2K.hxx"
#include "Cart3E.hxx"
#include "Cart3F.hxx"
#include "Cart4A50.hxx"
#include "Cart4K.hxx"
#include "CartAR.hxx"
#include "CartDPC.hxx"
@ -63,6 +64,8 @@ Cartridge* Cartridge::create(const uInt8* image, uInt32 size,
cartridge = new Cartridge3E(image, size);
else if(type == "3F")
cartridge = new Cartridge3F(image, size);
else if(type == "4A50")
cartridge = new Cartridge4A50(image);
else if(type == "4K")
cartridge = new Cartridge4K(image);
else if(type == "AR")
@ -187,7 +190,6 @@ string Cartridge::autodetectType(const uInt8* image, uInt32 size)
/* The above logic was written long before 3E support existed. It will
detect a 3E cart as 3F. Let's remedy that situation: */
if(type == "3F" && isProbably3E(image, size))
type = "3E";

View File

@ -0,0 +1,157 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Cart4A50.cxx,v 1.1 2006-06-12 14:12:51 stephena Exp $
//============================================================================
#include <assert.h>
#include "Cart4A50.hxx"
#include "System.hxx"
#include "Serializer.hxx"
#include "Deserializer.hxx"
#include <iostream>
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cartridge4A50::Cartridge4A50(const uInt8* image)
{
cerr << "Cartridge4A50 ctor\n";
/*
// Copy the ROM image into my buffer
for(uInt32 addr = 0; addr < 4096; ++addr)
{
myImage[addr] = image[addr];
}
*/
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cartridge4A50::~Cartridge4A50()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* Cartridge4A50::name() const
{
return "Cartridge4A50";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge4A50::reset()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge4A50::install(System& system)
{
/*
mySystem = &system;
uInt16 shift = mySystem->pageShift();
uInt16 mask = mySystem->pageMask();
// Make sure the system we're being installed in has a page size that'll work
assert((0x1000 & mask) == 0);
System::PageAccess access;
access.directPokeBase = 0;
access.device = this;
// Map ROM image into the system
for(uInt32 address = 0x1000; address < 0x2000; address += (1 << shift))
{
access.directPeekBase = &myImage[address & 0x0FFF];
mySystem->setPageAccess(address >> mySystem->pageShift(), access);
}
*/
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 Cartridge4A50::peek(uInt16 address)
{
return 0; // myImage[address & 0x0FFF];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge4A50::poke(uInt16, uInt8)
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge4A50::patch(uInt16 address, uInt8 value)
{
return false;
/*
myImage[address & 0x0FFF] = value;
return true;
*/
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge4A50::save(Serializer& out)
{
/*
string cart = name();
try
{
out.putString(cart);
}
catch(char *msg)
{
cerr << msg << endl;
return false;
}
catch(...)
{
cerr << "Unknown error in save state for " << cart << endl;
return false;
}
*/
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge4A50::load(Deserializer& in)
{
/*
string cart = name();
try
{
if(in.getString() != cart)
return false;
}
catch(char *msg)
{
cerr << msg << endl;
return false;
}
catch(...)
{
cerr << "Unknown error in load state for " << cart << endl;
return false;
}
*/
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8* Cartridge4A50::getImage(int& size)
{
/*
size = 4096;
return &myImage[0];
*/
return 0;
}

View File

@ -0,0 +1,114 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Cart4A50.hxx,v 1.1 2006-06-12 14:12:51 stephena Exp $
//============================================================================
#ifndef CARTRIDGE4A50_HXX
#define CARTRIDGE4A50_HXX
class Cartridge4A50;
class System;
class Serializer;
class Deserializer;
#include "bspf.hxx"
#include "Cart.hxx"
/**
This is the standard Atari 4K cartridge. These cartridges are
not bankswitched.
@author Bradford W. Mott
@version $Id: Cart4A50.hxx,v 1.1 2006-06-12 14:12:51 stephena Exp $
*/
class Cartridge4A50 : public Cartridge
{
public:
/**
Create a new cartridge using the specified image
@param image Pointer to the ROM image
*/
Cartridge4A50(const uInt8* image);
/**
Destructor
*/
virtual ~Cartridge4A50();
public:
/**
Get a null terminated string which is the device's name (i.e. "M6532")
@return The name of the device
*/
virtual const char* name() const;
/**
Reset cartridge to its power-on state
*/
virtual void reset();
/**
Install cartridge in the specified system. Invoked by the system
when the cartridge is attached to it.
@param system The system the device should install itself in
*/
virtual void install(System& system);
/**
Saves the current state of this device to the given Serializer.
@param out The serializer device to save to.
@return The result of the save. True on success, false on failure.
*/
virtual bool save(Serializer& out);
/**
Loads the current state of this device from the given Deserializer.
@param in The deserializer device to load from.
@return The result of the load. True on success, false on failure.
*/
virtual bool load(Deserializer& in);
virtual uInt8* getImage(int& size);
public:
/**
Get the byte at the specified address.
@return The byte at the specified address
*/
virtual uInt8 peek(uInt16 address);
/**
Change the byte at the specified address to the given value
@param address The address where the value should be stored
@param value The value to be stored at the address
*/
virtual void poke(uInt16 address, uInt8 value);
bool patch(uInt16 address, uInt8 value);
private:
// The 4K ROM image for the cartridge
// uInt8 myImage[4096];
};
#endif

View File

@ -6,6 +6,7 @@ MODULE_OBJS := \
src/emucore/Cart2K.o \
src/emucore/Cart3F.o \
src/emucore/Cart3E.o \
src/emucore/Cart4A50.o \
src/emucore/Cart4K.o \
src/emucore/CartAR.o \
src/emucore/CartCV.o \

View File

@ -1,482 +0,0 @@
GNU LIBRARY GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1991 Free Software Foundation, Inc.
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the library GPL. It is
numbered 2 because it goes with version 2 of the ordinary GPL.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Library General Public License, applies to some
specially designated Free Software Foundation software, and to any
other libraries whose authors decide to use it. You can use it for
your libraries, 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 library, or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link a program with the library, you must provide
complete object files to the recipients so that they can relink them
with the library, after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
Our method of protecting your rights has two steps: (1) copyright
the library, and (2) offer you this license which gives you legal
permission to copy, distribute and/or modify the library.
Also, for each distributor's protection, we want to make certain
that everyone understands that there is no warranty for this free
library. If the library is modified by someone else and passed on, we
want its recipients to know that what they have is not the original
version, 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 companies distributing free
software will individually obtain patent licenses, thus in effect
transforming the program into proprietary software. To prevent this,
we have made it clear that any patent must be licensed for everyone's
free use or not licensed at all.
Most GNU software, including some libraries, is covered by the ordinary
GNU General Public License, which was designed for utility programs. This
license, the GNU Library General Public License, applies to certain
designated libraries. This license is quite different from the ordinary
one; be sure to read it in full, and don't assume that anything in it is
the same as in the ordinary license.
The reason we have a separate public license for some libraries is that
they blur the distinction we usually make between modifying or adding to a
program and simply using it. Linking a program with a library, without
changing the library, is in some sense simply using the library, and is
analogous to running a utility program or application program. However, in
a textual and legal sense, the linked executable is a combined work, a
derivative of the original library, and the ordinary General Public License
treats it as such.
Because of this blurred distinction, using the ordinary General
Public License for libraries did not effectively promote software
sharing, because most developers did not use the libraries. We
concluded that weaker conditions might promote sharing better.
However, unrestricted linking of non-free programs would deprive the
users of those programs of all benefit from the free status of the
libraries themselves. This Library General Public License is intended to
permit developers of non-free programs to use free libraries, while
preserving your freedom as a user of such programs to change the free
libraries that are incorporated in them. (We have not seen how to achieve
this as regards changes in header files, but we have achieved it as regards
changes in the actual functions of the Library.) The hope is that this
will lead to faster development of free libraries.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, while the latter only
works together with the library.
Note that it is possible for a library to be covered by the ordinary
General Public License rather than by this special one.
GNU LIBRARY GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library which
contains a notice placed by the copyright holder or other authorized
party saying it may be distributed under the terms of this Library
General Public License (also called "this License"). Each licensee is
addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, 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 library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete 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 distribute a copy of this License along with the
Library.
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 Library or any portion
of it, thus forming a work based on the Library, 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) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
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 Library, 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 Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you 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.
If distribution of 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 satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also compile or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
c) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
d) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. 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.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library 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.
9. 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 Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
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.
11. 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 Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library 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 Library.
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.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library 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.
13. The Free Software Foundation may publish revised and/or new
versions of the Library 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 Library
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 Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
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
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "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
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. 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 LIBRARY 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
LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), 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 Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. 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 library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

View File

@ -1,10 +0,0 @@
package Rsynth::Audio;
use XSLoader;
our $VERSION = '0.01';
use Audio::Data ();
XSLoader::load "Rsynth::Audio";
1;
__END__

View File

@ -1,156 +0,0 @@
/*
Copyright (c) 1996, 2001 Nick Ing-Simmons. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
*/
#define PERL_NO_GET_CONTEXT
#include <EXTERN.h>
#include <perl.h>
#include <XSUB.h>
#include "Audio.m"
AudioVtab *AudioVptr;
#include "rsynth.h"
#include "english.h"
lang_t *lang = &English;
static void *
Rsynth_sample(void *user_data,float sample,unsigned nsamp, rsynth_t *rsynth)
{
dTHX;
Audio *au = (Audio *) user_data;
float *p = Audio_more(aTHX_ au,1);
/* FIXME - avoid this divide my adjusting gain on create */
*p = sample/32768;
return user_data;
}
static Elm_t *
SVtoElm(pTHX_ SV *sv)
{
if (sv_isobject(sv) && SvTYPE(SvRV(sv)) == SVt_PVHV)
{
HV *hv = (HV *) SvRV(sv);
SV **svp = hv_fetch(hv,"idx",3,0);
if (svp)
{
Elm_t *elm = &Elements[SvIV(*svp)];
return elm;
}
}
croak("%_ is not an Element",sv);
return NULL;
}
MODULE = Rsynth::Audio PACKAGE = Rsynth::Element PREFIX = elm_
void
elm_update(SV *sv)
CODE:
{
if (sv_isobject(sv) && SvTYPE(SvRV(sv)) == SVt_PVHV)
{
HV *hv = (HV *) SvRV(sv);
SV **svp = hv_fetch(hv,"idx",3,0);
if (svp)
{
Elm_t *elm = &Elements[SvIV(*svp)];
unsigned p;
for (p = 0; p < nEparm; p++)
{
char *pname = Ep_name[p];
svp = hv_fetch(hv,pname,strlen(pname),0);
if (svp)
{
if (SvROK(*svp) && SvTYPE(SvRV(*svp)) == SVt_PVAV)
{
AV *av = (AV *) SvRV(*svp);
if (av_len(av) != 4)
{
croak("%_->{%s} has %d values",sv,pname,av_len(av)+1);
}
svp = av_fetch(av, 0, 0);
if (svp)
{
elm->p[p].stdy = (float) SvNV(*svp);
}
svp = av_fetch(av, 1, 0);
if (svp)
{
elm->p[p].prop = (char) SvIV(*svp);
}
svp = av_fetch(av, 2, 0);
if (svp)
{
elm->p[p].ed = (char) SvIV(*svp);
}
svp = av_fetch(av, 3, 0);
if (svp)
{
elm->p[p].id = (char) SvIV(*svp);
}
svp = av_fetch(av, 4, 0);
if (svp)
{
elm->p[p].rk = (char) SvIV(*svp);
}
}
else
{
croak("%_->{%s} isn't an array",sv,pname);
}
}
}
XSRETURN(0);
}
}
croak("%_ is not an Element",sv);
XSRETURN(0);
}
MODULE = Rsynth::Audio PACKAGE = Rsynth::Audio PREFIX = rsynth_
PROTOTYPES: ENABLE
rsynth_t *
rsynth_new(char *Class, Audio *au, float F0Hz = 133.3, float ms_per_frame = 10.0, long gain = 57)
CODE:
{
speaker_t *speaker = rsynth_speaker(F0Hz, gain, Elements);
RETVAL = rsynth_init(au->rate,ms_per_frame, speaker,Rsynth_sample,0,au);
}
OUTPUT:
RETVAL
void
rsynth_interpolate(rsynth_t *rsynth,SV *elm,SV *f0ref = 0)
CODE:
{
STRLEN len = 0;
unsigned char *eptr = (unsigned char *) SvPV(elm,len);
float *f0 = 0;
unsigned nf0 = 0;
rsynth_flush(rsynth,rsynth_interpolate(rsynth, eptr, len, f0, nf0));
XSRETURN(0);
}
void
rsynth_pho(rsynth_t *rsynth, char *file, int dodur = 1, char *phones = "sampa")
void
rsynth_phones(rsynth_t *rsynth, char *s, int len = strlen(s))
void
say_string(rsynth_t *rsynth, char *s)
void
rsynth_term(rsynth_t *rsynth)
BOOT:
{
AudioVptr = (AudioVtab *) SvIV(perl_get_sv("Audio::Data::AudioVtab",0));
}

View File

@ -1,219 +0,0 @@
package Rsynth::Elements;
use strict;
use Exporter;
use base 'Exporter';
use vars qw(@EXPORT %elem %parms @pNames @eNames);
@EXPORT = qw(read_elements write_elements write_features feature
height front round features
%elem %parms @pNames @eNames);
use Getopt::Std;
# use Sampa ();
my %opt;
getopts('c',\%opt);
my %height = ( hgh => 1.0, lax => 0.8, smh => 0.67, mdl => 0.5, lmd => 0.33, low => 0 );
my %front = ( fnt => 1.0, cnt => 0.5, bck => 0);
my %round = ( unr => 0, rnd => 1);
my %unit = (f1 => 10, f2 => 20, f3 => 100);
sub rank
{
my $name = shift;
my $hash = shift;
my $e = shift;
my $f = $e->{features};
my @h = grep { exists $hash->{$_} } keys %$f;
die "No $name : ".$e->{sampa}.' '.join(' ',keys %$f).' : '.join(' ',keys %$hash) unless @h == 1;
return $hash->{$h[0]};
}
sub height { rank(height => \%height, @_) }
sub front { rank(front => \%front, @_) }
sub round { rank(round => \%round, @_) }
my %fset;
my @fNames;
my $file = "Elements.def";
sub NULL () {undef}
sub feature
{
my $f = shift;
unless (exists $fset{$f})
{
$fset{$f} = @fNames;
push(@fNames,$f);
}
}
sub features
{
my $e = shift;
return sort { $fset{$a} <=> $fset{$b} } keys %{$e->{features}};
}
foreach my $h (\%round,\%height,\%front)
{
foreach my $f ( sort { $h->{$a} <=> $h->{$b} } keys %$h )
{
feature($f);
}
}
feature('vwl');
feature('dip');
sub read_elements
{
$file = shift if @_;
open(my $eh,$file) || die "Cannot read $file:$!";
my $name;
while(<$eh>)
{
if (/^\{(".*",\s*.*),\s*(\/\*.*\*\/)?\s*$/)
{
my %args;
my (@args) = split(/\s*,\s*/,$1);
my @feat = split(/\|/,pop(@args));
my %feat;
foreach my $f (@feat)
{
next unless $f =~ /^[a-z]/i;
$feat{$f} = 1;
feature($f);
}
($name,@args) = map(eval($_),@args);
push(@args,\%feat);
foreach my $parm (qw(rk du ud unicode sampa features))
{
$args{$parm} = shift(@args);
$parms{$parm} = $args{$parm};
}
utf8::decode($args{unicode});
$elem{$name} = bless {%args,name => $name, idx => scalar(@eNames)},'Rsynth::Element';
push(@eNames,$name);
}
elsif (/^\s*\{\s*(.*?)\s*\},?\s*\/\*\s*(\w+)/)
{
my $parm = $2;
my @val = split(/\s*,\s*/,$1);
if ($parm =~ /^a/)
{
$val[0] = 0 if ($val[0] < 0);
$val[0] = sprintf("%+6.1f",$val[0]);
}
unless (exists $parms{$parm})
{
$parms{$parm} = $val[0];
push(@pNames,$parm);
}
$elem{$name}{$parm} = [@val];
}
}
my $nf = @fNames;
# warn "$nf features: @fNames\n";
close($eh);
}
sub write_features
{
for (my $i=0; $i < @fNames; $i++)
{
my $val = ($i) ? (1 << ($i-1)) : 0;
printf "#define $fNames[$i] 0x%08x\n",$val;
}
}
sub write_elements
{
my $fh = shift;
unless (ref $fh)
{
open(my $tmp,">$fh") || die "Cannot open $fh:$!";
$fh = $tmp;
}
binmode($fh,":utf8");
my $save = select $fh;
print $fh <<'END';
/*
Copyright (c) 1994,2001-2004 Nick Ing-Simmons. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA
*/
END
my @ename = @eNames;
while (@ename)
{
my $name = shift(@ename);
my @feat = features($elem{$name});
my $sampa = $elem{$name}{sampa};
my @args = qw(rk du ud);
@args = @{$elem{$name}}{@args};
my $uni = $elem{$name}{unicode};
utf8::encode($elem{$name}{unicode});
foreach my $k (qw(unicode sampa))
{
my $v = $elem{$name}{$k};
if (defined $v)
{
$v =~ s#([\\"])#\\$1#g;
$v =~ s/([^\x20-\x7e])/sprintf("\\%03o",ord($1))/eg;
}
$v = (defined $v) ? qq["$v"] : 'NULL';
push(@args,$v);
}
push(@args,(@feat) ? join('|',@feat) : 0);
printf qq({"$name", %3d,%2d,%2d,%s,%s,%s, /* [$uni] */\n {\n),@args;
my @pname = @pNames;
while (@pname)
{
my $parm = shift(@pname);
my @vals = @{$elem{$name}{$parm}};
if ($elem{$name}{features}{vwl} && exists $unit{$parm})
{
my $u = $unit{$parm};
$vals[0] = int($vals[0]/$u+0.5)*$u;
}
printf " {%6g,%4d,%3d,%3d,%3d}%s /* %-3s */\n",
@vals,((@pname) ? ',' : ' '),$parm;
}
printf " }\n}%s\n",((@ename) ? ",\n" : ' ');
}
select $save;
}
{
package Rsynth::Phones;
our %phtoelm;
do "Rsynth/phtoelm.def";
our @U = '@U';
sub NULL () {return ()};
sub COMMENT {}
sub enter
{
my ($sampa,@seq) = @_;
$phtoelm{$sampa} = [@seq];
}
}
1;

View File

@ -1,33 +0,0 @@
use ExtUtils::MakeMaker;
use File::Basename;
my $audio = ".../Audio";
eval "require Audio::Data";
unless ($@)
{
$audio = dirname($INC{"Audio/Data.pm"});
}
else
{
warn "_Need_ Audio::Data:$@"
}
WriteMakefile(
NAME => "Rsynth::Audio",
MYEXTLIB => "librsynth.a",
INC => "-I.. -I$audio",
TYPEMAPS => ["typemap","$audio/typemap"],
VERSION_FROM => "Audio.pm",
PREREQ_PM => { 'Audio::Data' => 1.000 },
PREREQ_FATAL => 1,
);
package MY;
sub post_initialize
{
my ($self) = @_;
my ($ret) = '';
$self->{PM}->{'phtoelm.def'} = $self->catfile('$(INST_LIBDIR)','phtoelm.def');
return $ret;
}

View File

@ -1,28 +0,0 @@
use Test::More( tests => 42 );
BEGIN { use_ok("Rsynth::Audio") }
BEGIN { use_ok("Rsynth::Elements") }
use Audio::Play;
read_elements("../Elements.def");
my $elm = '';
# Next line isn't general - all phones happen to be single SAMPA chars
for my $ph (split(//,'sInT.frQm.elIm@nts'))
{
my $list = $Rsynth::Phones::phtoelm{$ph};
ok(defined($list),"Mapping for $ph");
foreach my $ename (@{$list})
{
my $e = $elem{$ename};
ok(defined($e),"Element for $ename");
$elm .= chr($e->{idx});
$elm .= chr($e->{du});
}
}
my $au = Audio::Data->new(rate => 11025);
my $synth = Rsynth::Audio->new($au);
is(ref($synth),"Rsynth::Audio","Correct class");
$synth->interpolate($elm);
ok($au->duration > 1.0,"Created some samples");
my $svr = Audio::Play->new;
$svr->play($au) if $svr;

View File

@ -1,16 +0,0 @@
use Test::More( tests => 5 );
BEGIN { use_ok("Rsynth::Audio") }
use Audio::Play;
my $au = Audio::Data->new(rate => 11025);
my $synth = Rsynth::Audio->new($au);
is(ref($synth),"Rsynth::Audio","Correct class");
$synth->phones("sInTIsIs frQm p3l");
# print "# ",$au->duration,"\n";
ok($au->duration > 1.0,"Created some samples");
my $svr = Audio::Play->new;
$svr->play($au) if $svr;
$au->length(0);
is($au->duration,0,"Cleared samples");
$synth->say_string("Plain text too!");
ok($au->duration > 1.0,"Created some samples");
$svr->play($au) if $svr;

View File

@ -1,22 +0,0 @@
TYPEMAP
rsynth_t * T_RSYNTH
Elm_t * T_ELM
INPUT
T_RSYNTH
if (sv_isobject($arg)) {
$var = ($type) SvIV((SV*)SvRV($arg));
}
else
croak(\"$var is not an object\")
T_ELM
$var = ($type) SVtoElm(aTHX_ $arg);
OUTPUT
T_RSYNTH
sv_setref_iv($arg, (Class) ? Class : \"${Package}\", (IV) $var);
T_ELM
ElmToSV(aTHX_ $arg, $var);

View File

@ -1,19 +0,0 @@
#ifndef __AUFILE_H
#define __AUFILE_H
#ifdef __cplusplus
extern "C" {
#endif
extern int file_init(int argc,char *argv[]);
typedef void (*file_write_p)(int n, short *data);
typedef void (*file_term_p)(void);
extern file_write_p file_write;
extern file_term_p file_term;
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,272 +0,0 @@
/*
Copyright (c) 1994,2001-2002 Nick Ing-Simmons. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA
*/
#include <stdlib.h>
#include <string.h>
#include <locale.h>
#include "charset.h"
void
init_locale(void)
{
char *s = setlocale(LC_ALL, "");
if (s)
{
s = setlocale(LC_CTYPE, NULL);
if (s && !strcmp(s, "C"))
{
s = setlocale(LC_CTYPE, "iso_8859_1");
if (!s)
s = setlocale(LC_CTYPE, "C");
}
}
}
int
deaccent(int ch)
{
/* Cast to char (type of litterals) as signedness may differ */
switch ((char)ch)
{
case 'à':
case 'á':
case 'â':
case 'ã':
case 'ä':
case 'å':
return 'a';
case 'ç':
return 'c';
break;
case 'è':
case 'é':
case 'ê':
case 'ë':
return 'e';
case 'ì':
case 'í':
case 'î':
case 'ï':
return 'i';
case 'ñ':
return 'n';
case 'ò':
case 'ó':
case 'ô':
case 'õ':
case 'ö':
return 'o';
case 'ù':
case 'ú':
case 'û':
case 'ü':
return 'u';
case 'ý':
case 'ÿ':
return 'y';
case 'À':
case 'Á':
case 'Â':
case 'Ã':
case 'Ä':
case 'Å':
return 'A';
case 'Ç':
return 'C';
case 'È':
case 'É':
case 'Ê':
case 'Ë':
return 'E';
case 'Ì':
case 'Í':
case 'Î':
case 'Ï':
return 'I';
case 'Ñ':
return 'N';
case 'Ò':
case 'Ó':
case 'Ô':
case 'Õ':
case 'Ö':
return 'O';
case 'Ù':
case 'Ú':
case 'Û':
case 'Ü':
return 'U';
case 'Ý':
return 'Y';
}
if ((ch & 0xFF) > 0x7F)
abort();
return ch;
}
int
accent(int a, int c)
{
if (a && c)
{
switch (a)
{
case '<':
case ',':
switch (c)
{
case 'c':
return 'ç';
case 'C':
return 'Ç';
default:
return c;
}
case '~':
switch (c)
{
case 'n':
return 'ñ';
case 'a':
return 'ã';
case 'o':
return 'õ';
case 'N':
return 'Ñ';
case 'A':
return 'Ã';
case 'O':
return 'Õ';
default:
return c;
}
case '\'':
switch (c)
{
case 'a':
return 'á';
case 'e':
return 'é';
case 'i':
return 'í';
case 'o':
return 'ó';
case 'u':
return 'ú';
case 'y':
return 'ý';
case 'A':
return 'Á';
case 'E':
return 'É';
case 'I':
return 'Í';
case 'O':
return 'Ó';
case 'U':
return 'Ú';
case 'Y':
return 'Ý';
default:
return c;
}
case '`':
switch (c)
{
case 'a':
return 'à';
case 'e':
return 'è';
case 'i':
return 'ì';
case 'o':
return 'ò';
case 'u':
return 'ù';
case 'A':
return 'À';
case 'E':
return 'È';
case 'I':
return 'Ì';
case 'O':
return 'Ò';
case 'U':
return 'Ù';
default:
return c;
}
case '^':
switch (c)
{
case 'a':
return 'â';
case 'e':
return 'ê';
case 'i':
return 'î';
case 'o':
return 'ô';
case 'u':
return 'û';
case 'A':
return 'Â';
case 'E':
return 'Ê';
case 'I':
return 'Î';
case 'O':
return 'Ô';
case 'U':
return 'Û';
default:
return c;
}
case '"':
switch (c)
{
case 'a':
return 'ä';
case 'e':
return 'ë';
case 'i':
return 'ï';
case 'o':
return 'ö';
case 'u':
return 'ü';
case 'y':
return 'ÿ';
case 'A':
return 'Ä';
case 'E':
return 'Ë';
case 'I':
return 'Ï';
case 'O':
return 'Ö';
case 'U':
return 'Ü';
default:
return c;
}
}
}
return c;
}

View File

@ -1,20 +0,0 @@
#ifndef CHARSET_H
#define CHARSET_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef HAS_NL_LANGINFO
#include <langinfo.h>
#endif
extern void init_locale(void);
extern int deaccent(int ch);
extern int accent(int a, int c);
#ifdef __cplusplus
}
#endif
#endif /* CHARSET_H */

View File

@ -1,75 +0,0 @@
#ifdef HAVE_DB_H
#include <fcntl.h>
#include <db.h>
#define DB_HANDLE DB *
#define DATUM DBT
#define DATUM_SIZE(d) d.size
#define DATUM_DATA(d) d.data
#define DATUM_SET(d,val,len) \
do { memset(&d,0,sizeof(d)); \
d.data = (val); \
d.size = (len); \
} while (0)
#define DB_OPEN_WRITE(db, path) \
do { \
int status = db_create(&db,NULL,0); \
if (!status) \
status = (db->open)(db, NULL, path, NULL, DB_HASH, DB_CREATE, 0644); \
if (status) \
db = NULL; \
} while (0)
#define DB_OPEN_READ(db, path) \
do { \
int status = db_create(&db,NULL,0); \
if (!status) \
status = (db->open)(db, NULL, path, NULL, DB_HASH, DB_RDONLY, 0644); \
if (status) \
db = NULL; \
} while (0)
#define DB_STORE(db, key, data) \
db->put(db, NULL, &key, &data, 0)
#define DB_FETCH(db, key, data) \
do { \
data.flags = DB_DBT_MALLOC; \
data.data = NULL; \
db->get(db, NULL, &key, &data, 0); \
} while (0)
#define DB_CLOSE(db) db->close(db,0)
#else /* LIBDB */
#ifdef HAVE_LIBGDBM
#include <gdbm.h>
/* Don't force block size let gdbm/os decide */
#define BLOCK_SIZE 0
#ifndef GDBM_FAST
/* Tolerate older versions of gdbm ... */
#define GDBM_FAST 0
#endif
#define DB_HANDLE GDBM_FILE
#define DATUM datum
#define DATUM_SIZE(d) d.dsize
#define DATUM_DATA(d) d.dptr
#define DATUM_SET(d,val,len) do { d.dptr = (val); d.dsize = (len); } while (0)
#define DB_STORE(db, key, data) gdbm_store(db, key, data, GDBM_INSERT)
#define DB_OPEN_WRITE(db, path) db = gdbm_open(path, BLOCK_SIZE, GDBM_WRCREAT | GDBM_FAST, 0644, NULL)
#define DB_OPEN_READ(db, path) db = gdbm_open(path, BLOCK_SIZE, GDBM_READER, 0644, NULL)
#define DB_CLOSE(db) gdbm_close(db)
#define DB_FETCH(db,key,data) \
data = gdbm_fetch(db, key)
#endif /* LIBGDBM */
#endif /* LIBDB */

View File

@ -1,749 +0,0 @@
/*
Contributed to rsynth by a forgotten author (based on english.c)
Changes Copyright (c) 1994,2001-2002 Nick Ing-Simmons. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA
*/
#include "config.h"
#include <stdio.h>
#include <ctype.h>
#include "darray.h"
#include "lang.h"
#include "say.h"
#include "deutsch.h"
/* $Id: deutsch.c,v 1.1 2006-06-11 07:13:24 urchlay Exp $
*/
char *deutsch_id = "$Id: deutsch.c,v 1.1 2006-06-11 07:13:24 urchlay Exp $";
static unsigned cardinal(long int value, darray_ptr phone);
static unsigned ordinal(long int value, darray_ptr phone);
static int vowel(int chr, int maybe);
static int consonant(int chr);
static Rule *rules(int ch);
/*
deutsche phoneme
**
**
**
** The Phoneme codes:
**
** <blank>, %, p, t, k, b, d, g, m, n, N, f, T, h, v, D,
** j, tS, dZ, S, x, Z, s, z,
** l, r, rr R, w, u, U, i, I,
** A, &, V, @, o, O, 0, e, 3,
** eI aI oI aU @U I@ e@ U@ O@ oU
**
**
** Rules are made up of four parts:
**
** The left context.
** The text to match.
** The right context.
** The phonemes to substitute for the matched text.
**
** Procedure:
**
** Seperate each block of letters (apostrophes included)
** and add a space on each side. For each unmatched
** letter in the word, look through the rules where the
** text to match starts with the letter in the word. If
** the text to match is found and the right and left
** context patterns also match, output the phonemes for
** that rule and skip to the next unmatched letter.
**
**
** Special Context Symbols:
**
** # One or more vowels
** : Zero or more consonants
** ^ One consonant.
** $ duplicate consonant
** . One of B, D, V, G, J, L, M, N, R, W or Z (voiced
** consonants)
** % One of ER, E, ES, ED, ING, ELY (a suffix)
** (Found in right context only)
** + One of E, I or Y (a "front" vowel)
**
*/
/* Context definitions */
static char Anything[] = "";
/* No context requirement */
static char Nothing[] = " ";
/* Context is beginning or end of word */
static char Silent[] = "";
/* No phonemes */
#define LEFT_PART 0
#define MATCH_PART 1
#define RIGHT_PART 2
#define OUT_PART 3
/*0 = Punctuation */
/*
** LEFT_PART MATCH_PART RIGHT_PART OUT_PART
*/
static Rule punct_rules[] =
{
{Anything, " ", Anything, " "},
{Anything, "-", Anything, ""},
{".", "'S", Anything, "z"},
{"#:.E", "'S", Anything, "z"},
{"#", "'S", Anything, "z"},
{Anything, "'", Anything, ""},
{Anything, ",", Anything, " "},
{Anything, ".", Anything, " "},
{Anything, "?", Anything, " "},
{Anything, "!", Anything, " "},
{Anything, 0, Anything, Silent},
};
static Rule A_rules[] =
{
/* {Anything, "A", Nothing, "@"}, */
{Nothing, "A", Nothing, "A"},
{Anything, "A", Nothing, "V"},
/* {Anything, "A", "^+:#", "&"}, */
/* {Anything, "A", "^%", "a"}, */
{Anything, "AU", Anything, "aU"},
/* {Anything, "A", Anything, "a"}, */
{Anything, "AE", Anything, "ee"}, /* Ä */
{Anything, "AR", Anything, "V@"}, /* narkose */
{Nothing, "AB", "B", "Vb "}, /* abbilden */
{Nothing, "AN", "N", "Vn "}, /* annehmen */
/* {Anything, "A", "^^", "V"}, geht nicht! koennen auch verschiedene sein */
{Anything, "A", "$", "V"},
/* {Anything, "A", "ß", "A"}, *//* das */
/* {Anything, "A", "S", "A"}, *//* das */
{Anything, "A", "H", "VV"},
/* {Anything, "A", Anything, "V"}, */
{Anything, "A", Anything, "A"},
{Anything, 0, Anything, Silent},
};
static Rule B_rules[] =
{
{"#", "BB", "#", "b"},
{Anything, "B", Anything, "b"},
{Anything, 0, Anything, Silent},
};
static Rule C_rules[] =
{
/* {Nothing, "CH", "^", "k"}, */
/* {Anything, "CH", "I", "x"}, //chinese */
/* {Anything, "CH", Nothing, "x"}, //charakter */
{Nothing, "CH", Anything, "k"}, /* charakter */
{Anything, "CH", Anything, "x"},
{Anything, "CI", "EN", "S"},
{Anything, "CK", Anything, "k"},
{Anything, "COM", "%", "kVm"},
{Anything, "C", Anything, "k"},
{Anything, 0, Anything, Silent},
};
static Rule D_rules[] =
{
{"#:", "DED", Nothing, "dId"},
{".E", "D", Nothing, "d"},
{"#:^E", "D", Nothing, "t"},
{"#", "DD", "#", "d"},
{"#", "DD", Nothing, "d"},
{Anything, "D", Anything, "d"},
{Anything, 0, Anything, Silent},
};
static Rule E_rules[] =
{
/* {Nothing, "E", Nothing, "ee"}, */
/* {Nothing, Anything, "E", "ee"}, */
{":", "E", Nothing, "@"},
{Anything, "ER", Nothing, "3"},
{Anything, "EV", "ER", "ev"},
/* {"#:", "ER", "#", "3"}, */
{Anything, "ER", "#", "er"},
{Anything, "EW", Anything, "ev"},
{Anything, "EI", Anything, "aI"},
{Anything, "EU", Anything, "oI"},
{Anything, "EH", Anything, "eee"}, /* ??? ge-habt <-> geh-abt */
{Anything, "EE", Anything, "eee"},
{Anything, "E", "^^", "e"},
{Anything, "E", "$", "e"},
{Anything, "EN", Nothing, "@n"},
{Anything, "E", Anything, "ee"},
/* {Anything, "E", Anything, "e"}, */
{Anything, 0, Anything, Silent},
};
static Rule F_rules[] =
{
{"F", "F", "F", "f f"},
/* {Anything, "F", "F", ""}, */
{"#", "FF", "#", "f"},
{"#", "FF", Nothing, "f"},
{Anything, "F", Anything, "f"},
{Anything, 0, Anything, Silent},
};
static Rule G_rules[] =
{
{Nothing, "GE", "E", "g@ "}, /* geehrte */
{Nothing, "GIN", Nothing, "dZin"},
{Anything, "GREAT", Anything, "greIt"},
{"#", "GG", "#", "g"},
{Anything, "G", Anything, "g"},
{Anything, 0, Anything, Silent},
};
static Rule H_rules[] =
{
{Anything, "H", "#", "h"},
{Anything, "H", Anything, ""},
{Anything, 0, Anything, Silent},
};
static Rule I_rules[] =
{
{Anything, "IE", Anything, "i"},
{Anything, "IER", Anything, "i3"},
{Anything, "IQUE", Anything, "ik"},
{Anything, "I", "ß", "i"},
{Anything, "I", "H", "i"},
{Anything, "I", "$", "I"},
{Anything, "I", Anything, "i"},
{Anything, 0, Anything, Silent},
};
static Rule J_rules[] =
{
{Anything, "J", Anything, "j"},
{Anything, 0, Anything, Silent},
};
static Rule K_rules[] =
{
{Nothing, "K", "N", ""},
{Anything, "K", Anything, "k"},
{Anything, 0, Anything, Silent},
};
static Rule L_rules[] =
{
{"#", "LL", "#", "l"},
{"#", "LL", Nothing, "l"},
{Anything, "L", Anything, "l"},
{Anything, 0, Anything, Silent},
};
static Rule M_rules[] =
{
{"#", "MM", "#", "m"},
{"#", "MM", Nothing, "m"},
{Anything, "M", Anything, "m"},
{Anything, 0, Anything, Silent},
};
static Rule N_rules[] =
{
{"#", "NN", "#", "n"},
{"#", "NN", Nothing, "n"},
{Anything, "N", Anything, "n"},
{Anything, 0, Anything, Silent},
};
static Rule O_rules[] =
{
{Anything, "OE", Anything, "@@"},
{Nothing, "OK", Nothing, "okei"},
{Anything, "OY", Anything, "oI"},
{Anything, "OI", Anything, "oI"},
{"C", "O", "N", "0"},
{Anything, "O", "$", "0"},
{Anything, "O", "ß", "oo"},
{Anything, "O", "H", "oo"},
{Anything, "O", Anything, "o"},
{Anything, 0, Anything, Silent},
};
static Rule P_rules[] =
{
{"#", "PP", "#", "p"},
{"#", "PP", Nothing, "p"},
{Anything, "PH", Anything, "f"},
{Anything, "PEOP", Anything, "pip"},
{Anything, "POW", Anything, "paU"},
{Anything, "PUT", Nothing, "pUt"},
{Anything, "P", Anything, "p"},
{Anything, 0, Anything, Silent},
};
static Rule Q_rules[] =
{
{Anything, "QUAR", Anything, "kwar"},
{Anything, "QU", Anything, "kw"},
{Anything, "Q", Anything, "k"},
{Anything, 0, Anything, Silent},
};
static Rule R_rules[] =
{
{Nothing, "RE", "^#", "re"},
{"#", "RR", "#", "r"},
{"#", "RR", Nothing, "r"},
{Anything, "R", Anything, "r"},
{Anything, 0, Anything, Silent},
};
static Rule S_rules[] =
{
{Anything, "SH", Anything, "S"},
{"#", "SS", "#", "s"},
{"#", "SS", Nothing, "s"},
/* {Anything, "S", "S", ""}, */
{".", "S", Nothing, "z"},
{"#:.E", "S", Nothing, "z"},
{"#:^##", "S", Nothing, "z"},
{"#:^#", "S", Nothing, "s"},
{"U", "S", Nothing, "s"},
{" :#", "S", Nothing, "z"},
{Anything, "SCH", Anything, "S"},
{Anything, "S", Anything, "s"},
{Anything, 0, Anything, Silent},
};
static Rule T_rules[] =
{
{"#", "TT", "#", "t"},
{"#", "TT", Nothing, "t"},
{Nothing, "TWO", Anything, "tu"},
{Anything, "TION", Nothing, "tsion"},
{Anything, "T", Anything, "t"},
{Anything, 0, Anything, Silent},
};
static Rule U_rules[] =
{
{Nothing, "UN", "N", "un "}, /* un-nötig */
{Anything, "U", "$", "U"},
{Anything, "U", "H", "uu"},
{Anything, "UE", Anything, "I"},
{Anything, "U", Anything, "u"},
{Anything, 0, Anything, Silent},
};
static Rule V_rules[] =
{
{Anything, "VIEW", Anything, "vju"},
{Nothing, "V", Anything, "f"},
{Anything, "V", Anything, "v"},
{Anything, 0, Anything, Silent},
};
static Rule W_rules[] =
{
{Anything, "WHERE", Anything, "hwer"},
{Anything, "WHAT", Anything, "hw0t"},
{Anything, "WHO", Anything, "hu"},
{Anything, "W", Anything, "v"},
{Anything, "W", Nothing, "f"}, /* kiew */
{Anything, 0, Anything, Silent},
};
static Rule X_rules[] =
{
{Anything, "X", Anything, "ks"},
{Anything, 0, Anything, Silent},
};
static Rule Y_rules[] =
{
{Nothing, "YES", Anything, "jes"},
{Nothing, "Y", Anything, "I"},
{Anything, "Y", Anything, "I"},
{Anything, 0, Anything, Silent},
};
static Rule Z_rules[] =
{
{Anything, "Z", Anything, "ts"},
{Anything, 0, Anything, Silent},
};
static Rule Uml_rules[] = /* jms */
{
{Anything, "ÄU", Anything, "oI"},
{Anything, "ß", Anything, "s"},
{Anything, "Ä", Anything, "ee"},
{Anything, "Ö", Anything, "@@"},
{Anything, "Ü", Anything, "I"},
{Anything, 0, Anything, Silent},
};
static Rule *Rules[] =
{
punct_rules,
A_rules, B_rules, C_rules, D_rules, E_rules, F_rules, G_rules,
H_rules, I_rules, J_rules, K_rules, L_rules, M_rules, N_rules,
O_rules, P_rules, Q_rules, R_rules, S_rules, T_rules, U_rules,
V_rules, W_rules, X_rules, Y_rules, Z_rules, Uml_rules
};
static int
vowel(int chr, int maybe)
{
if (!isalpha(chr))
return 0;
switch (chr)
{
case 'A':
case 'E':
case 'I':
case 'Ä':
case 'Ö':
case 'Ü':
case 'O':
case 'U':
case 'Y':
case 'a':
case 'e':
case 'i':
case 'ä':
case 'ö':
case 'ü':
case 'o':
case 'u':
case 'y':
return 1;
}
return 0;
}
static int
consonant(int chr)
{
return (isalpha(chr) && !vowel(chr,0));
}
static char *ASCII[] =
{
"null", "", "", "",
"", "", "", "",
"", "", "", "",
"", "", "", "",
"", "", "", "",
"", "", "", "",
"", "", "", "",
"", "", "", "",
"blenk", "ausrufezeichen", "double quote", "hash",
"dollar", "prozent", "ampersand", "quote",
"klammer auf", "klammer zu", /*"asterisk" */ "mal", "plus",
"comma", "minus", "punkt", "slash",
"null", "eins", "zwei", "drei",
"vier", "fünf", "sechs", "sieben",
"acht", "neun", "doppelpunkt", "semicolon",
"kleiner als", "gleich", "grösser als", "fragezeichen",
#ifndef ALPHA_IN_DICT
"at",
"a", "bee", "zee",
"dee", "ee", "eff", "ge",
"ha", "i", "jott", "ka",
"ell", "em", "en", "oo",
"pee", "kuh", "err", "es",
"tee", "uh", "vau", "we",
"iks", "ypsilon", "zed", "klammer auf",
#else /* ALPHA_IN_DICT */
"at", "A", "B", "C",
"D", "E", "F", "G",
"H", "I", "J", "K",
"L", "M", "N", "O",
"P", "Q", "R", "S",
"T", "U", "V", "W",
"X", "Y", "Z", "klammer auf",
#endif /* ALPHA_IN_DICT */
"back slash", "klammer zu", "zirkumflex", "unterstrich",
#ifndef ALPHA_IN_DICT
"back quote",
"a", "bee", "zee",
"dee", "ee", "eff", "ge",
"ha", "ii", "jott", "ka",
"ell", "em", "en", "oo",
"pee", "kuh", "err", "es",
"tee", "uh", "vau", "we",
"iks", "ypsilon", "zed", "klammer auf",
#else /* ALPHA_IN_DICT */
"back quote", "A", "B", "C",
"D", "E", "F", "G",
"H", "I", "J", "K",
"L", "M", "N", "O",
"P", "Q", "R", "S",
"T", "U", "V", "W",
"X", "Y", "Z", "open brace",
#endif /* ALPHA_IN_DICT */
"senkrechter strich", "klammer zu", "tilde", "löschen",
NULL
};
/*
** Integer to Readable ASCII Conversion Routine.
**
** Synopsis:
**
** say_cardinal(value)
** long int value; -- The number to output
**
** The number is translated into a string of words
**
*/
static char *Cardinals[] =
{
"null", "eins", "zwei", "drei",
"vier", "fünf", "sechs", "sieben",
"acht", "neun",
"zehn", "elf", "zwölf", "dreizehn",
"vierzehn", "fünfzehn", "sechszehn", "siebzehn",
"achtzehn", "neunzehn"
};
static char *Twenties[] =
{
"zwanzig", "dreissig", "vierzig", "fünfzig",
"sechzig", "siebzig", "achtzig", "neunzig"
};
static char *Ordinals[] =
{
"nullter", "erster", "zweiter", "dritter",
"vierter", "fünfter", "sechster", "siebter",
"achter", "neunter",
"zehnter", "elfter", "zwölfter", "dreizehnter",
"vierzehnter", "fünfzehnter", "sechszehnter", "siebzehnter",
"achtzehnter", "neunzehnter"
};
static char *Ord_twenties[] =
{
"zwanzigster", "dreissigster", "vierzigster", "fünfzigster",
"sechzigster", "siebzigster", "achtzigster", "neunzigster"
};
/*
** Translate a number to phonemes. This version is for CARDINAL numbers.
** Note: this is recursive.
*/
static unsigned
cardinal(long int value, darray_ptr phone)
{
unsigned nph = 0;
if (value < 0)
{
nph += xlate_string("minus", phone);
value = (-value);
if (value < 0) /* Overflow! -32768 */
{
nph += xlate_string("zu viele", phone);
return nph;
}
}
if (value >= 1000000000L)
/* Billions */
{
nph += cardinal(value / 1000000000L, phone);
nph += xlate_string("milliarde", phone); /* this is different !! jms */
value = value % 1000000000;
if (value == 0)
return nph; /* Even billion */
if (value < 100)
nph += xlate_string("und", phone);
/* as in THREE BILLION AND FIVE */
}
if (value >= 1000000L)
/* Millions */
{
nph += cardinal(value / 1000000L, phone);
nph += xlate_string("million", phone);
value = value % 1000000L;
if (value == 0)
return nph; /* Even million */
if (value < 100)
nph += xlate_string("und", phone);
/* as in THREE MILLION AND FIVE */
}
/* Thousands 1000..1099 2000..99999 */
/* 1100 to 1999 is eleven-hunderd to ninteen-hunderd */
if ((value >= 1000L && value <= 1099L) || value >= 2000L)
{
nph += cardinal(value / 1000L, phone);
nph += xlate_string("tausend", phone);
value = value % 1000L;
if (value == 0)
return nph; /* Even thousand */
if (value < 100)
nph += xlate_string("und", phone);
/* as in THREE THOUSAND AND FIVE */
}
if (value >= 100L)
{
nph += xlate_string(Cardinals[value / 100], phone);
nph += xlate_string("hundert", phone);
value = value % 100;
if (value == 0)
return nph; /* Even hundred */
}
if ((value % 10) > 0 && value > 20)
nph += xlate_string(Cardinals[value % 10], phone); /* jms */
if ((value % 10) > 0 && value > 20)
nph += xlate_string("und", phone); /* jms */
if (value >= 20)
{
nph += xlate_string(Twenties[(value - 20) / 10], phone);
/* value = value % 10; weg jms */
/* if (value == 0) weg jms */
/* return nph; weg jms *//* Even ten */
}
if (value < 20)
nph += xlate_string(Cardinals[value], phone); /* jms */
return nph;
}
/*
** Translate a number to phonemes. This version is for ORDINAL numbers.
** Note: this is recursive.
*/
static unsigned
ordinal(long int value, darray_ptr phone)
{
unsigned nph = 0;
if (value < 0)
{
nph += xlate_string("minus", phone);
value = (-value);
if (value < 0) /* Overflow! -32768 */
{
nph += xlate_string("zu viele", phone);
return nph;
}
}
if (value >= 1000000000L)
/* Billions */
{
nph += cardinal(value / 1000000000L, phone);
value = value % 1000000000;
if (value == 0)
{
nph += xlate_string("milliardste", phone);
return nph; /* Even billion */
}
nph += xlate_string("milliarde", phone);
if (value < 100)
nph += xlate_string("und", phone);
/* as in THREE BILLION AND FIVE */
}
if (value >= 1000000L)
/* Millions */
{
nph += cardinal(value / 1000000L, phone);
value = value % 1000000L;
if (value == 0)
{
nph += xlate_string("millionster", phone);
return nph; /* Even million */
}
nph += xlate_string("million", phone);
if (value < 100)
nph += xlate_string("und", phone);
/* as in THREE MILLION AND FIVE */
}
/* Thousands 1000..1099 2000..99999 */
/* 1100 to 1999 is eleven-hunderd to ninteen-hunderd */
if ((value >= 1000L && value <= 1099L) || value >= 2000L)
{
nph += cardinal(value / 1000L, phone);
value = value % 1000L;
if (value == 0)
{
nph += xlate_string("tausendster", phone);
return nph; /* Even thousand */
}
nph += xlate_string("tausend", phone);
if (value < 100)
nph += xlate_string("und", phone);
/* as in THREE THOUSAND AND FIVE */
}
if (value >= 100L)
{
nph += xlate_string(Cardinals[value / 100], phone);
value = value % 100;
if (value == 0)
{
nph += xlate_string("hundertster", phone);
return nph; /* Even hundred */
}
nph += xlate_string("hundert", phone);
}
if (value >= 20)
{
if ((value % 10) == 0)
{
nph += xlate_string(Ord_twenties[(value - 20) / 10], phone);
return nph; /* Even ten */
}
nph += xlate_string(Twenties[(value - 20) / 10], phone);
value = value % 10;
}
nph += xlate_string(Ordinals[value], phone);
return nph;
}
static Rule *
rules(int ch)
{
int type = 0;
if (isupper(ch) || ch == 'ß')
type = ch - 'A' + 1;
if (type > 'Z' - 'A' + 2)
type = 'Z' - 'A' + 2; /* umlaute , jms */
return Rules[type];
}
lang_t Deutsch =
{
ASCII,
"punkt",
vowel,
consonant,
ordinal,
cardinal,
rules
};

View File

@ -1,14 +0,0 @@
#ifndef __DEUTCSH_H
#define __DEUTCSH_H
#ifdef __cplusplus
extern "C" {
#endif
extern lang_t Deutsch;
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,21 +0,0 @@
/* $Id: dict.h,v 1.1 2006-06-11 07:13:24 urchlay Exp $
*/
#ifndef DICT_H
#define DICT_H
#include "lang.h"
#ifdef __cplusplus
extern "C" {
#endif
extern char *dict_path;
extern int dict_init(const char *dictname);
extern void dict_term(void);
#ifdef __cplusplus
}
#endif
#endif /* DICT_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +0,0 @@
#ifndef __ENGLISH_H
#define __ENGLISH_H
#include "lang.h"
#ifdef __cplusplus
extern "C" {
extern lang_t English;
}
#endif
#endif

View File

@ -1,17 +0,0 @@
/* $Id: getargs.h,v 1.2 2006-06-11 21:49:07 stephena Exp $
*/
#ifndef GETARGS_H
#define GETARGS_H
#ifdef __cplusplus
extern "C" {
#endif
extern int getargs(char *module,int argc,char *argv[],...);
extern int help_only;
#ifdef __cplusplus
}
#endif
#endif /* GETARGS_H */

View File

@ -18,9 +18,9 @@
*/
#include "config.h"
/* $Id: holmes.c,v 1.1 2006-06-11 07:13:25 urchlay Exp $
/* $Id: holmes.c,v 1.2 2006-06-12 14:12:52 stephena Exp $
*/
char *holmes_id = "$Id: holmes.c,v 1.1 2006-06-11 07:13:25 urchlay Exp $";
char *holmes_id = "$Id: holmes.c,v 1.2 2006-06-12 14:12:52 stephena Exp $";
#include <stdio.h>
#include <ctype.h>
#include <assert.h>
@ -28,9 +28,6 @@ char *holmes_id = "$Id: holmes.c,v 1.1 2006-06-11 07:13:25 urchlay Exp $";
#include <math.h>
#include "rsynth.h"
#include "darray.h"
#include "getargs.h"
#include "plotparm.h"
#include "hplay.h"
typedef struct {
float v; /* boundary value */

View File

@ -1,39 +0,0 @@
/*
Copyright (c) 1994,2001-2003 Nick Ing-Simmons. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA
*/
/* $Id: hplay.h,v 1.2 2006-06-11 21:49:08 stephena Exp $
*/
#ifndef __HPLAY_H
#define __HPLAY_H
#ifdef __cplusplus
extern "C" {
#endif
extern char *program;
extern long samp_rate;
extern int audio_init(int argc, char *argv[]);
extern void audio_term(void);
extern void audio_play(int n, short *data);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,55 +0,0 @@
#ifndef LANG_H
#define LANG_H
#ifdef __cplusplus
extern "C" {
#endif
#include "darray.h"
extern char **dialect;
/* Rule is an array of 4 character pointers */
typedef struct rule_s
{
char *left;
char *match;
char *right;
char *output;
} Rule;
typedef struct lang_s
{
char **char_name;
char *point;
int (*vowel)(int chr,int maybe);
int (*consonant)(int chr);
unsigned (*ordinal)(long int value,darray_ptr phone);
unsigned (*cardinal)(long int value,darray_ptr phone);
Rule *(*rules)(int ch);
unsigned char *(*lookup)(const char *s, unsigned n);
} lang_t;
extern unsigned char *dict_find(const char *s, unsigned n);
/* FIXME - the following was the original code
I guess it needs to be defined in SpeakJet ??
For now, it's defined in english.h
extern lang_t *lang;
*/
static lang_t *lang = 0;
#define isvowel(c,m) (*lang->vowel)(c,m)
#define isconsonant(c) (*lang->consonant)(c)
#define xlate_ordinal(v,p) (*lang->ordinal)(v,p)
#define xlate_cardinal(v,p) (*lang->cardinal)(v,p)
#define dict_find(s,n) ((lang->lookup) ? (*lang->lookup)(s,n) : 0)
#define have_dict (lang->lookup != 0)
#ifdef __cplusplus
}
#endif
#endif /* LANG_H */

View File

@ -1,17 +1,12 @@
MODULE := src/emucore/rsynth
MODULE_OBJS := \
src/emucore/rsynth/charset.o \
src/emucore/rsynth/darray.o \
src/emucore/rsynth/deutsch.o \
src/emucore/rsynth/elements.o \
src/emucore/rsynth/english.o \
src/emucore/rsynth/holmes.o \
src/emucore/rsynth/opsynth.o \
src/emucore/rsynth/phones.o \
src/emucore/rsynth/phtoelm.o \
src/emucore/rsynth/say.o \
src/emucore/rsynth/text.o \
src/emucore/rsynth/trie.o
MODULE_DIRS += \

View File

@ -26,7 +26,6 @@
#define PI 3.1415927
#endif
#include "rsynth.h"
#include "plotparm.h"
#define SYNC_CASCADE

View File

@ -19,9 +19,9 @@
*/
#include "config.h"
/* $Id: phtoelm.c,v 1.1 2006-06-11 07:13:26 urchlay Exp $
/* $Id: phtoelm.c,v 1.2 2006-06-12 14:12:52 stephena Exp $
*/
char *phtoelm_id = "$Id: phtoelm.c,v 1.1 2006-06-11 07:13:26 urchlay Exp $";
char *phtoelm_id = "$Id: phtoelm.c,v 1.2 2006-06-12 14:12:52 stephena Exp $";
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
@ -30,8 +30,6 @@ char *phtoelm_id = "$Id: phtoelm.c,v 1.1 2006-06-11 07:13:26 urchlay Exp $";
#include "useconfig.h"
#include "rsynth.h"
#include "trie.h"
#include "hplay.h"
// #include "aufile.h"
#include "phfeat.h"
@ -80,7 +78,7 @@ enter(char *p, ...)
static void
enter_phonemes(void)
{
#include "Rsynth/phtoelm.def"
#include "phtoelm.def"
}
trie_ptr

View File

@ -1,10 +0,0 @@
#ifndef __PLOTPARM_H
#define __PLOTPARM_H
#ifdef __cplusplus
extern "C" {
extern FILE *par_file;
}
#endif
#endif

View File

@ -1,365 +0,0 @@
/*
Copyright (c) 1994,2001-2003 Nick Ing-Simmons. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA
*/
#include "config.h"
/* jms: deutsch */
/* $Id: say.c,v 1.2 2006-06-11 21:49:09 stephena Exp $
$Log: not supported by cvs2svn $
Revision 1.1 2006/06/11 07:13:27 urchlay
Forgive the gigantic commit; I'm importing "rsynth". It's not really such
a big library, and it's not commonly installed anywhere, and it's GPL.
Actually, a good chunk of rsynth can be removed (all the stuff related
to perl modules and text-to-speech, which we won't need for Stella). I'll
prune it when I figure out exactly what I can keep...
* Revision 1.13 1994/11/08 13:30:50 a904209
* 2.0 release
*
* Revision 1.12 1994/11/04 13:32:31 a904209
* 1.99.1 - Change configure stuff
*
* Revision 1.11 1994/11/02 10:55:31 a904209
* Add autoconf. Tested on SunOS/Solaris
*
* Revision 1.10 1994/10/04 17:12:50 a904209
* 3rd pre-release
*
* Revision 1.9 1994/10/04 09:08:27 a904209
* Next Patch merge
*
* Revision 1.8 1994/10/03 08:41:47 a904209
* 2nd pre-release
*
* Revision 1.7 1994/09/19 15:48:29 a904209
* Split hplay.c, gdbm dictionary, start of f0 contour, netaudio and HP ports
*
* Revision 1.6 1994/04/15 16:47:37 a904209
* Edits for Solaris2.3 (aka SunOs 5.3)
*
* Revision 1.5 1994/02/24 15:03:05 a904209
* Added contributed linux, NeXT and SGI ports.
*
* Revision 1.4 93/11/18 16:29:06 a904209
* Migrated nsyth.c towards Jon's scheme - merge still incomplete
*
* Revision 1.3 93/11/16 14:32:44 a904209
* Added RCS Ids, partial merge of Jon's new klatt/parwave
*
* Revision 1.3 93/11/16 14:00:58 a904209
* Add IDs and merge Jon's klatt sources - incomplete
*
*/
#ifdef __cplusplus
extern "C" {
#endif
char *say_id = "$Id: say.c,v 1.2 2006-06-11 21:49:09 stephena Exp $";
extern char *Revision;
#include <stdio.h>
#include <ctype.h>
#include "useconfig.h"
#include <math.h>
#ifdef OS2
#include <signal.h>
#include <setjmp.h>
#include <float.h>
#endif /* OS2 */
#include "darray.h"
#include "rsynth.h"
#include "hplay.h"
#include "dict.h"
#include "lang.h"
#include "text.h"
#include "getargs.h"
#include "phones.h"
#include "aufile.h"
#include "charset.h" /* national differences ,jms */
#include "english.h"
#include "deutsch.h"
#include "say.h"
unsigned
spell_out(char *word, int n, darray_ptr phone)
{
unsigned nph = 0;
#ifndef DEBUG
fprintf(stderr, "Spelling '%.*s'\n", n, word);
#endif /* DEBUG */
while (n-- > 0) {
char *spellword = lang->char_name[deaccent(*word++) & 0x7F];
fprintf(stderr, " %s\n", spellword);
nph += NRL(spellword, strlen(spellword), phone);
darray_append(phone, ' ');
nph += 1;
}
return nph;
}
int
suspect_word(char *w, int n)
{
unsigned char *s = (unsigned char *) w;
int i = 0;
int seen_lower = 0;
int seen_upper = 0;
int seen_vowel = 0;
int last = 0;
#ifdef GERMAN
if (n == 1)
return 1; /* jms: 1 char is not a word */
/* jms only "I" is... */
#endif /* GERMAN */
for (i = 0; i < n; i++) {
int ch = *s++;
if (i && last != '-' && isupper(ch))
seen_upper = 1;
if (islower(ch)) {
seen_lower = 1;
ch = toupper(ch);
}
if (isvowel(ch, 1))
seen_vowel = 1;
last = ch;
}
last = !seen_vowel || (seen_upper && seen_lower) || !seen_lower;
#ifdef DEBUG
fprintf(stderr, "%d %.*s v=%d u=%d l=%d\n", last, n, w, seen_vowel,
seen_upper, seen_lower);
#endif
return last;
}
static unsigned
xlate_word(char *word, int n, darray_ptr phone, int verbose)
{
unsigned nph = 0;
if (*word != '[') {
if (have_dict) {
unsigned char *p = dict_find(word, n);
if (p) {
unsigned char *s = p;
while (*s) {
char *x = dialect[(unsigned) (*s++)];
while (*x) {
darray_append(phone, *x++);
nph++;
}
}
darray_append(phone, ' ');
free(p);
return nph + 1;
}
else {
/* If supposed word contains '.' or '-' try breaking it up... */
char *h = word;
while (h < word + n) {
if (*h == '.' || *h == '-') {
nph += xlate_word(word, h++ - word, phone, verbose);
nph += xlate_word(h, word + n - h, phone, verbose);
return nph;
}
else
h++;
}
}
}
if (suspect_word(word, n)) {
nph = spell_out(word, n, phone);
return (nph);
}
else {
#ifndef DEBUG
if (have_dict || verbose)
fprintf(stderr, "Guess '%.*s'\n", n, word);
#endif
nph += NRL(word, n, phone);
}
}
else {
if ((++word)[(--n) - 1] == ']')
n--;
while (n-- > 0) {
darray_append(phone, *word++);
nph++;
}
}
// darray_append(phone, ' ');
return nph + 1;
}
unsigned
_xlate_string(rsynth_t * rsynth, char *string, darray_ptr phone)
{
unsigned nph = 0;
unsigned char *s = (unsigned char *) string;
int ch;
while (isspace(ch = *s))
s++;
while ((ch = *s)) {
unsigned char *word = s;
if (isalpha(ch)) {
while (isalpha(ch = *s)
|| ((ch == '\'' || ch == '-' || ch == '.')
&& isalpha(s[1])))
s++;
if (!ch || isspace(ch) || ispunct(ch)
|| (isdigit(ch) && !suspect_word((char *) word, s - word))) {
nph += xlate_word((char *) word, s - word, phone, rsynth_verbose(rsynth));
}
else {
while ((ch = *s) && !isspace(ch) && !ispunct(ch))
s++;
nph += spell_out((char *) word, s - word, phone);
}
}
else if (isdigit(ch) || (ch == '-' && isdigit(s[1]))) {
int sign = (ch == '-') ? -1 : 1;
long value = 0;
if (sign < 0)
ch = *++s;
while (isdigit(ch = *s)) {
value = value * 10 + ch - '0';
s++;
}
if (ch == '.' && isdigit(s[1])) {
word = ++s;
nph += xlate_cardinal(value * sign, phone);
nph += xlate_string(lang->point, phone);
while (isdigit(ch = *s))
s++;
nph += spell_out((char *) word, s - word, phone);
}
else {
/* check for ordinals, date, time etc. can go in here */
nph += xlate_cardinal(value * sign, phone);
}
}
else if (ch == '[' && strchr((char *) s, ']')) {
unsigned char *word = s;
while (*s && *s++ != ']')
/* nothing */ ;
nph += xlate_word((char *) word, s - word, phone, rsynth_verbose(rsynth));
}
else if (ispunct(ch)) {
switch (ch) {
/* On end of sentence flush the buffer ... */
case '!':
case '?':
case '.':
#if 1
case ';':
case ',':
case '(':
case ')':
#endif
if ((!s[1] || isspace(s[1])) && phone->items) {
if (rsynth) {
rsynth_phones(rsynth,
(char *) darray_find(phone, 0),
phone->items);
phone->items = 0;
}
}
s++;
darray_append(phone, ' ');
break;
case '"': /* change pitch ? */
case ':':
case '-':
#if 0
case ';':
case ',':
case '(':
case ')':
#endif
s++;
darray_append(phone, ' ');
break;
case '[':
{
unsigned char *e =
(unsigned char *) strchr((char *) s, ']');
if (e) {
s++;
while (s < e)
darray_append(phone, *s++);
s = e + 1;
break;
}
}
default:
nph += spell_out((char *) word, 1, phone);
s++;
break;
}
}
else {
while ((ch = *s) && !isspace(ch))
s++;
nph += spell_out((char *) word, s - word, phone);
}
while (isspace(ch = *s))
s++;
}
return nph;
}
unsigned
xlate_string(char *string, darray_ptr phone)
{
return _xlate_string(0, string, phone);
}
void
say_string(rsynth_t * rsynth, char *s)
{
darray_t phone;
darray_init(&phone, sizeof(char), 256); /* chg jms */
_xlate_string(rsynth, s, &phone);
if (phone.items)
rsynth_phones(rsynth, (char *) darray_find(&phone, 0), phone.items);
darray_free(&phone);
}
void
say_file(rsynth_t * rsynth, FILE * f)
{
darray_t line;
darray_t phone;
darray_init(&line, sizeof(char), 128);
darray_init(&phone, sizeof(char), 128);
while (darray_fget(f, &line)) {
_xlate_string(rsynth, (char *) darray_find(&line, 0), &phone);
line.items = 0;
}
if (phone.items)
rsynth_phones(rsynth,
(char *) darray_find(&phone, 0), phone.items);
darray_free(&phone);
darray_free(&line);
}
#ifdef __cplusplus
}
#endif

View File

@ -1,49 +0,0 @@
/*
Copyright (c) 1994,2001-2003 Nick Ing-Simmons. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA
*/
/* $Id: say.h,v 1.1 2006-06-11 07:13:27 urchlay Exp $
*/
#ifndef SAY_H
#define SAY_H
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Routines that do text -> phonetic conversion */
extern unsigned xlate_string(char *string,darray_ptr phone);
extern int suspect_word(char *s,int n);
extern unsigned spell_out(char *word,int n,darray_ptr phone);
/* text -> phonetic -> elements -> sampled audio */
struct rsynth_s;
extern void say_string(struct rsynth_s *rsynth, char *s);
extern void say_file(struct rsynth_s *rsynth, FILE * f);
#ifdef __cplusplus
}
#endif
#endif /* SAY_H */

View File

@ -1,369 +0,0 @@
/*
Derived from sources on comp.lang.speech belived to be public domain.
Changes Copyright (c) 1994,2001-2002 Nick Ing-Simmons.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA
*/
#include "config.h"
/* $Id: text.c,v 1.1 2006-06-11 07:13:27 urchlay Exp $
jms: added rule for duplicate consonant
jms: changed isvowel function
*/
char *text_id = "$Id: text.c,v 1.1 2006-06-11 07:13:27 urchlay Exp $";
#include <stdio.h>
#include <ctype.h>
#include "useconfig.h"
#include "darray.h"
#include "phtoelm.h"
#include "lang.h"
#include "text.h"
#include "say.h"
int rule_debug = 0;
#define FALSE (0)
#define TRUE (!0)
/*
** English to Phoneme translation.
**
** Rules are made up of four parts:
**
** The left context.
** The text to match.
** The right context.
** The phonemes to substitute for the matched text.
**
** Procedure:
**
** Seperate each block of letters (apostrophes included)
** and add a space on each side. For each unmatched
** letter in the word, look through the rules where the
** text to match starts with the letter in the word. If
** the text to match is found and the right and left
** context patterns also match, output the phonemes for
** that rule and skip to the next unmatched letter.
**
**
** Special Context Symbols:
**
** # One or more vowels
** : Zero or more consonants
** ^ One consonant.
** . One of B, D, V, G, J, L, M, N, R, W or Z (voiced
** consonants)
** % One of ER, E, ES, ED, ING, ELY (a suffix)
** (Right context only)
** + One of E, I or Y (a "front" vowel)
** $ Duplicate consonant (for German)
** = S or nothing (Right only) plurals etc.
*/
static int leftmatch(unsigned char *pattern, unsigned char *context);
static int
leftmatch(unsigned char *pattern, unsigned char *context)
/* first char of pattern to match in text */
/* last char of text to be matched */
{
unsigned char *pat;
unsigned char *text;
int count;
if (*pattern == '\0')
/* null string matches any context */
{
return TRUE;
}
/* point to last character in pattern string */
count = strlen((char *) pattern);
pat = pattern + (count - 1);
text = context;
for (; count > 0; pat--, count--)
{
/* First check for simple text or space */
if (isalpha(*pat & 0xFF) || *pat == '\'' || *pat == ' ')
{
if (*pat != *text)
return FALSE;
else
{
text--;
continue;
}
}
switch (*pat)
{
case '#': /* One or more vowels */
if (!isvowel(*text,0))
return FALSE;
text--;
while (isvowel(*text,0))
text--;
break;
case ':': /* Zero or more consonants */
while (isconsonant(*text))
text--;
break;
case '^': /* One consonant */
if (!isconsonant(*text))
return FALSE;
text--;
break;
case '$': /* duplicate consonant jms */
if (!isconsonant(*text))
return FALSE;
if (*text != *(text - 1))
return FALSE;
text--;
text--;
break;
case '.': /* B, D, V, G, J, L, M, N, R, W, Z */
if (*text != 'b' && *text != 'd' && *text != 'v'
&& *text != 'g' && *text != 'j' && *text != 'l'
&& *text != 'm' && *text != 'n' && *text != 'r'
&& *text != 'w' && *text != 'z')
return FALSE;
text--;
break;
case '+': /* E, I or Y (front vowel) */
if (*text != 'e' && *text != 'i' && *text != 'y')
return FALSE;
text--;
break;
case '%':
default:
fprintf(stderr, "Bad char in left rule: '%c'\n", *pat);
return FALSE;
}
}
return TRUE;
}
static int rightmatch(unsigned char *pattern, unsigned char *context);
static int
rightmatch(unsigned char *pattern, unsigned char *context)
/* first char of pattern to match in text */
/* last char of text to be matched */
{
unsigned char *pat;
unsigned char *text;
if (*pattern == '\0')
/* null string matches any context */
return TRUE;
pat = pattern;
text = context;
for (pat = pattern; *pat != '\0'; pat++)
{
/* First check for simple text or space */
if (isalpha(*pat & 0xFF) || *pat == '\'' || *pat == ' ')
{
if (*pat != *text)
return FALSE;
else
{
text++;
continue;
}
}
switch (*pat)
{
case '#': /* One or more vowels */
if (!isvowel(*text,0))
return FALSE;
text++;
while (isvowel(*text,0))
text++;
break;
case '=': /* Terminal, optional 's' */
if (*text == 's' && text[1] == ' ')
text++;
if (*text != ' ')
return FALSE;
text++;
break;
case ':': /* Zero or more consonants */
while (isconsonant(*text))
text++;
break;
case '^': /* One consonant */
if (!isconsonant(*text))
return FALSE;
text++;
break;
case '$': /* duplicate consonant jms */
if (!isconsonant(*text))
return FALSE;
if (*text != *(text + 1))
return FALSE;
text++;
text++;
break;
case '.': /* B, D, V, G, J, L, M, N, R, W, Z */
if (*text != 'b' && *text != 'd' && *text != 'v'
&& *text != 'g' && *text != 'j' && *text != 'l'
&& *text != 'm' && *text != 'n' && *text != 'r'
&& *text != 'w' && *text != 'z')
return FALSE;
text++;
break;
case '+': /* E, I or Y (front vowel) */
if (*text != 'e' && *text != 'i' && *text != 'y')
return FALSE;
text++;
break;
case '%': /* ER, E, ES, ED, ING, ELY (a suffix) */
if (*text == 'e')
{
text++;
if (*text == 'l')
{
text++;
if (*text == 'y')
{
text++;
break;
}
else
{
text--; /* Don't gobble L */
break;
}
}
else if (*text == 'r' || *text == 's' || *text == 'd')
text++;
break;
}
else if (*text == 'i')
{
text++;
if (*text == 'n')
{
text++;
if (*text == 'g')
{
text++;
break;
}
}
return FALSE;
}
else
return FALSE;
default:
fprintf(stderr, "Bad char in right rule:'%c'\n", *pat);
return FALSE;
}
}
return TRUE;
}
static int find_rule(void *arg, out_p out, unsigned char *word, int index, Rule(*rules));
static int
find_rule(void *arg, out_p out, unsigned char *word, int index, Rule *rules)
{
if (rule_debug)
printf("Looking for %c in %c rules\n",word[index],*rules->match);
for (;;) /* Search for the rule */
{
Rule *rule = rules++;
unsigned char *match = (unsigned char *) rule->match;
int remainder;
if (match == 0) /* bad symbol! */
{
if (rule_debug)
fprintf(stderr, "Error: Can't find rule for: '%c' in \"%s\"\n",
word[index], word);
return index + 1; /* Skip it! */
}
for (remainder = index; *match != '\0'; match++, remainder++)
{
if (*match != word[remainder])
break;
}
if (*match != '\0')
{
continue; /* found missmatch */
}
if (!leftmatch((unsigned char *) rule->left, &word[index - 1]))
continue;
if (!rightmatch((unsigned char *) rule->right, &word[remainder]))
continue;
if (rule_debug)
printf("...%s|%s|%s...=> %s succeded!\n", rule->left, rule->match, rule->right, rule->output);
(*out) (arg, rule->output);
return remainder;
}
}
void
guess_word(void *arg, out_p out, unsigned char *word)
{
int index; /* Current position in word */
index = 1; /* Skip the initial blank */
do
{
index = find_rule(arg, out, word, index, lang->rules(word[index]));
}
while (word[index] != '\0');
}
int
NRL(char *s, unsigned int n, darray_ptr phone)
{
int old = phone->items;
unsigned char *word = (unsigned char *) malloc(n + 3);
unsigned char *d = word;
*d++ = ' ';
while (n-- > 0)
{
unsigned ch = *s++ & 0xFF;
if (isupper(ch))
ch = tolower(ch);
*d++ = ch;
}
*d++ = ' ';
*d = '\0';
guess_word(phone, darray_cat, word);
free(word);
return phone->items - old;
}

View File

@ -1,37 +0,0 @@
/*
Copyright (c) 1994,2001-2003 Nick Ing-Simmons. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA
*/
/* $Id: text.h,v 1.1 2006-06-11 07:13:27 urchlay Exp $
*/
#ifndef TEXT_H
#define TEXT_H
#ifdef __cplusplus
extern "C" {
#endif
extern int rule_debug;
typedef void (*out_p)(void *arg,char *s);
extern int NRL(char *s,unsigned n,darray_ptr phone);
extern void guess_word(void *arg, out_p out, unsigned char *word);
#ifdef __cplusplus
}
#endif
#endif /* TEXT_H */