jesd-0.0.7/0000755000175000017500000000000007244230407011115 5ustar mjj29mjj29jesd-0.0.7/COPYING0000644000175000017500000006131407017304454012157 0ustar mjj29mjj29 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 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. Copyright (C) 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. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! jesd-0.0.7/README0000644000175000017500000000240507157120642012000 0ustar mjj29mjj29 JEsd a pure Java(TM) Enlightenment Sound Daemon by JCraft Inc. http://www.jcraft.com/jesd/ Last modified: Mon Sep 11 09:09:25 UTC 2000 Description =========== JEsd is a re-implementation of EsounD in Java program. JEsd includes a audio server and libraries for communicating with 'esd'. JEsd has included the Ogg Vorbis support experimentally. Documentation ============= Read before asking. * README files all over the source tree have info related to the stuff in the directories. * INSTALL has instructions for using. * ChangeLog: what changed from the previous version? Directories & Files in the Source Tree ====================================== * com/ has source trees of JEsd. * example/ has some samples, which demonstrate the usage of client side code. Copyrights & Disclaimers ======================== JEsd is copyrighted by JCraft Inc. and is licensed through the GNU Library General Public License. Read the COPYING file for the complete license. Credits ======= All credits goes to authors and contributers of EsounD and EsounD compatible applications. If you have any comments, suggestions and questions, write us at jesd@jcraft.com jesd-0.0.7/INSTALL0000644000175000017500000000555107157171752012166 0ustar mjj29mjj29 How to use JEsd ==================================================================== Last modified: Mon Sep 11 09:14:38 UTC 2000 SUPPORTED PLATFORMS =================== JEsd includes a daemon program, which corresponds to 'esd' and classes for communicating with 'esd', which correspond to 'libesd'. That daemon program is implemented with JavaTM Sound API. So, it will be available on any platform, which support that API. At present, it seems that JavaTM Sound API is only available in Java2(JDK 1.3beta or later). Here, we list supported platforms, which we have confirmed already. - Windows 98 On the other hand, client side codes will be available on JDK 1.0* or later. REQUIREMENTS: ============= The following softwares are required to use the audio server functionality. - JDK 1.3beta or later - esd compliant applications, for example x11amp, xmms, etc,. USAGE: ====== Before running an audio server, confirm you have already installed JDK 1.3beta or later. Then type, javac -O -g:none com/jcraft/jesd/*.java java com.jcraft.jesd.Daemon The audio server will wait for connections at port 16001. To use this daemon, just specify a location, where JEsd is running, to esd compatible applications. Suppose that an audio server is running on some machine, named 'foo', and you have Un*x machine, named 'bar'. Try next commands on machine 'bar' export ESPEAKER=foo x11amp Concerning the usage of client side library, we have tried to mimic APIs of 'libesd' and some sample programs in an 'examples' directory will be helpful for understanding it. At present, documents for that library has not been written. Please bear with us. Ogg Vorbis Support: =================== Since 0.0.6, JEsd's audio server has supported the Ogg Vorbis. In this support, you can enjoy Ogg Vorbis bit-streams, which will be sent via EsounD protocol. To use this functionality, you need pure Java Ogg Vorbis decoder(JOrbis) and its source code and binaries are available at http://www.jcraft.com/joribs/ . 1. Download a JOrbis archive from http://www.jcraft.com/joribs/ and make it to be accessible through the CLASSAPTH. 2. Run the audio server, java com.jcraft.jesd.DaemonWithVorbis 3. Suppose that the audio server is running on some machine, named 'foo', and you have Redhat box, named 'bar'. Try next commands on machine 'bar' $ cat foo.ogg | esdcat -s foo $ esdloop -s foo bar.ogg $ esdsample -s foo -d bar.ogg Note 1. foo.ogg and bar.ogg are Ogg files and bar.ogg must be small. Note 2. 'esdplay' will not work, because 'esdplay' uses some API, which checks a file format if it is WAV or not. 4. Of course, you can enjoy WAV files on this new audio server seamlessly, $ cat foo.wav | esdcat -s foo Ogg files are available at http://vorbis.com/listen.html and if you have Ogg Vorbis CODEC from xiph.org, you can make ogg files by your self. jesd-0.0.7/ChangeLog0000644000175000017500000000342307244230372012672 0ustar mjj29mjj29 ChangeLog of WeirdX ==================================================================== Last modified: Mon Feb 19 14:42:04 UTC 2001 Changes since version 0.0.6: ............................ - fixed resources leak in SamplePlayer and StreamPlayer. - added a doc, 'misc/EsounD-protocol.txt', which is in draft status, but first descriptions about the undocumented EsoundD protocol. Changes since version 0.0.5: ............................ - added a spport for the Ogg Vorbis bitstream. JEsd's audio server accepts Ogg Vorbis bitstreams directly via EsounD protocol and works as the Ogg Vorbis player. Changes since version 0.0.4: ............................ - added a spport for the request 'ESD_PROTO_LATENCY'. This request has been added since esound-0.2.14(?). - fixed a bug in processing the request 'ESD_PROTO_ALL_INFO'. By this bug, freeamp had not worked with JEsd. - added a hack for working aroud a bug in J2SE Plug-in. Check the constructor of StreamPlayer class. Changes since version 0.0.3: ............................ - changed to use JS(Java Sound) API 1.0, which is included with the Java 2 SDK, Standard Edition 1.3 RC1 release, and as part of the JMF 2.0 FCS release. Previous versions had used JS API 0.9. This API has been out of date and been incompatible with JS API 1.0. Changes since version 0.0.2: ............................ - fixed to respond correctly to server_info and all_info requests. Previous versions had sent back garbages in responding to these requests. Recent mpg123(for example, version 0.59r, which is included in RH 6.1) uses the server_info request and had not worked with the audio server of JEsd. Changes since version 0.0.1: ............................ - added client side code for communicating with esd. jesd-0.0.7/STATUS0000644000175000017500000000131707031021557012063 0ustar mjj29mjj29Current Status: version 0.0.2 ==================================================================== Last modified: Sat Dec 25 01:52:21 UTC 1999 Tons of things are left to be implemented. Here, missing things are listed. * sending mixed buffer output as a stream. ESD_PROTO_STREAM_MON * esd remote control, ESD_PROTO_STREAM_PAN, ESD_PROTO_SAMPLE_PAN, * esd remote management funcionality. ESD_PROTO_SERVER_INFO, ESD_PROTO_ALL_INFO, ESD_PROTO_SUBSCRIBE, ESD_PROTO_UNSUBSCRIBE * esd status checking funcionality. ESD_PROTO_STANDBY_MONE * free and reclaim /dev/dsp functionality. ESD_PROTO_STANDBY, ESD_PROTO_RESUME * filtering mixed buffer output as a stream. ESD_PROTO_STREAM_FILT jesd-0.0.7/com/0000755000175000017500000000000007017302663011675 5ustar mjj29mjj29jesd-0.0.7/com/jcraft/0000755000175000017500000000000007017302665013150 5ustar mjj29mjj29jesd-0.0.7/com/jcraft/jesd/0000755000175000017500000000000007244161243014072 5ustar mjj29mjj29jesd-0.0.7/com/jcraft/jesd/Auth.class0000644000175000017500000000132207244161223016016 0ustar mjj29mjj29-/      ! "#$% ESD_KEY_LENI ConstantValueesd_key[B()VCodeinit(Ljava/lang/String;)Vauth([B)Z(Lcom/jcraft/jesd/IO;)Z & '( ) *+ ,- .- java/lang/Exceptioncom/jcraft/jesd/Authjava/lang/Objectjava/lang/StringgetBytes()[Bcom/jcraft/jesd/IOreadByte([B)VreadPad(I)VwriteInt   * * *(NB"<*3T<3*37#<M*,**,<M<jesd-0.0.7/com/jcraft/jesd/Auth.java0000644000175000017500000000322707047563741015654 0ustar mjj29mjj29/* JEsd * Copyright (C) 1999 JCraft Inc. * * Written by: 1999 ymnk * * This program 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 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 Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jesd; class Auth{ static final int ESD_KEY_LEN=16; static byte[] esd_key = null; static void init(String key){ if(key!=null){ // if(key.length()!=ESD_KEY_LEN){ // } esd_key = key.getBytes(); } } synchronized static boolean auth(byte[] key){ if(esd_key==null){ esd_key = new byte[ESD_KEY_LEN]; for(int i=0;i ? @ A BC D BE F GHI ; J KL M N GO KOPQinLjava/io/InputStream;outLjava/io/OutputStream;socketLjava/net/Socket;ba[Bsaia()VCodereadInt()I Exceptions readShortwriteInt(I)V writeShortsetInputStream(Ljava/io/InputStream;)VsetOutputStream(Ljava/io/OutputStream;)V setSocket(Ljava/net/Socket;)V getSocket()Ljava/net/Socket;readByte([B)V([BII)VreadPad writeByte(B)VwritePadclose !"      R ST +, UV -.W XYjava/io/IOException 35Z [5 78 75 :"com/jcraft/jesd/IOjava/lang/Objectjava/net/SocketgetInputStream()Ljava/io/InputStream;getOutputStream()Ljava/io/OutputStream;java/io/InputStreamread([BII)Ijava/io/OutputStreamwrite  !"#6********$%& '%& ()& *)& +,#*+-.#*+/0#"*+*+ *+ & 12#*3%#2&** < Y*3~& 34# *++& 35#;/6*+ 6 Yd>`=۱& 6)#2&!** = Y& 78#!*T**& 7)#*& 74# *++& 75# *+& 9)#, *T**& :"#**& jesd-0.0.7/com/jcraft/jesd/Client.java0000644000175000017500000001704607157107077016173 0ustar mjj29mjj29/* JEsd * Copyright (C) 1999 JCraft Inc. * * Written by: 1999 ymnk * * This program 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 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 Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jesd; //import javax.media.sound.midi.*; //import javax.media.sound.sampled.*; import javax.sound.midi.*; import javax.sound.sampled.*; class Client extends Thread { // for bounds checking static final int ESD_PROTO_MAX=23; static final int ESD_NAME_MAX=128; static final int ESD_KEY_LEN=16; static final int ESD_ENDIAN_KEY=('E' << 24)+('N' << 16)+('D' << 8)+('N'); java.net.Socket socket; IO io; boolean swap; int request; Client(java.net.Socket socket) throws java.io.IOException{ int reply=1; // yes this.socket=socket; java.io.InputStream in=socket.getInputStream(); java.io.OutputStream out=socket.getOutputStream(); byte[] esd_key = new byte[ESD_KEY_LEN]; in.read(esd_key, 0, ESD_KEY_LEN); if(!Auth.auth(esd_key)){ reply=0; } byte[] endian = new byte[4]; in.read(endian, 0, 4); if(endian[0]=='E'){ io=new IOMSB();} else{ io=new IOLSB();} io.setSocket(socket); io.writeInt(reply); if(reply==1) add(this); if(reply==0){ try{io.close();}catch(Exception e){}; io=null; } } public void run(){ if(io==null) return; int reqType; int format, rate, size, res, version, ok, foo; int left_scale, right_scale; int id=0, stream_id; Sample sample; byte[] name=new byte[ESD_NAME_MAX]; try{ while (true) { reqType=io.readInt(); //System.out.println("reqType="+Integer.toHexString(reqType)); switch(reqType){ case JEsd.ESD_PROTO_STREAM_PLAY: format=io.readInt(); //System.out.println("format="+Integer.toHexString(format)); rate=io.readInt(); //System.out.println("rate="+rate); io.readByte(name); //System.out.println("name="+new String(name)); { StreamPlayer player= new StreamPlayer(format, rate, new String(name)); if(player.outputLine!=null){ player.play(io); } else{ try{io.close();}catch(Exception e){} } del(this); return; } // break; case JEsd.ESD_PROTO_STREAM_MON: format=io.readInt(); //System.out.println("format="+Integer.toHexString(format)); rate=io.readInt(); //System.out.println("rate="+rate); io.readByte(name); //System.out.println("name="+new String(name)); while(true){ io.writeByte(0); } case JEsd.ESD_PROTO_SAMPLE_CACHE: format=io.readInt(); //System.out.println("format="+Integer.toHexString(format)); rate=io.readInt(); //System.out.println("rate="+rate); size=io.readInt(); //System.out.println("size="+size); io.readByte(name); //System.out.println("name="+new String(name)); sample=new Sample(this, format, rate, size, new String(name)); io.writeInt(sample.id); sample.fill(io); io.writeInt(sample.id); break; case JEsd.ESD_PROTO_SAMPLE_LOOP: foo=io.readInt(); //System.out.println("sample loop: "+foo); sample=Sample.get(foo); if(sample!=null){ SamplePlayer player=new SamplePlayer(sample); player.loop(); } else{foo=0;} io.writeInt(foo); break; case JEsd.ESD_PROTO_SAMPLE_PLAY: foo=io.readInt(); //System.out.println("sample play: "+foo); sample=Sample.get(foo); if(sample!=null){ SamplePlayer player=new SamplePlayer(sample); player.play(); } else{foo=0;} io.writeInt(1); break; case JEsd.ESD_PROTO_SAMPLE_STOP: foo=io.readInt(); //System.out.println("sample="+foo); sample=Sample.get(foo); if(sample!=null && sample.player!=null){ sample.player.stop_playing(); } else{foo=0;} io.writeInt(foo); break; case JEsd.ESD_PROTO_SAMPLE_KILL: foo=io.readInt(); //System.out.println("sample="+foo); sample=Sample.get(foo); if(sample!=null && sample.player!=null){ sample.player.kill(); } else{foo=0;} io.writeInt(foo); break; case JEsd.ESD_PROTO_SAMPLE_FREE: foo=io.readInt(); //System.out.println("sample="+foo); sample=Sample.get(foo); if(sample!=null)sample.free(); io.writeInt(1); break; case JEsd.ESD_PROTO_LOCK: res=(Auth.auth(io)?1:0); io.writeInt(res); // ok break; case JEsd.ESD_PROTO_UNLOCK: res=(Auth.auth(io)?1:0); io.writeInt(res); // ok break; case JEsd.ESD_PROTO_STANDBY: res=(Auth.auth(io)?1:0); io.writeInt(res); // ok break; case JEsd.ESD_PROTO_RESUME: res=(Auth.auth(io)?1:0); io.writeInt(res); // ok break; case JEsd.ESD_PROTO_SAMPLE_GETID: io.readByte(name); //System.out.println("name="+new String(name)); sample=Sample.get(new String(name)); id=(sample==null?0:sample.id); io.writeInt(id); // ok break; case JEsd.ESD_PROTO_SERVER_INFO: Daemon.protoServerInfo(io); break; case JEsd.ESD_PROTO_ALL_INFO: Daemon.protoAllInfo(io); break; case JEsd.ESD_PROTO_SAMPLE_PAN: foo=io.readInt(); //System.out.println("sample="+foo); left_scale=io.readInt(); //System.out.println("left_scale="+left_scale); right_scale=io.readInt(); //System.out.println("right_scale="+right_scale); io.writeInt(1); // ok break; case JEsd.ESD_PROTO_STREAM_PAN: stream_id=io.readInt(); //System.out.println("stream_id="+stream_id); left_scale=io.readInt(); //System.out.println("left_scale="+left_scale); right_scale=io.readInt(); //System.out.println("right_scale="+right_scale); //Player p=Player.get(stream_id); //System.out.println("player="+p); io.writeInt(1); // ok break; case JEsd.ESD_PROTO_STANDBY_MODE: io.writeInt(1/*ESM_ON_STANDBY*/); // ok break; case JEsd.ESD_PROTO_LATENCY: { int amount; if((JEsd.esd_audio_format&JEsd.ESD_STEREO)!=0){ if((JEsd.esd_audio_format&JEsd.ESD_BITS16)!=0) amount=(44100*(JEsd.ESD_BUF_SIZE+64))/JEsd.esd_audio_rate; else amount=(44100*(JEsd.ESD_BUF_SIZE+128))/JEsd.esd_audio_rate; } else { if((JEsd.esd_audio_format&JEsd.ESD_BITS16)!=0) amount=(2*44100*(JEsd.ESD_BUF_SIZE+128))/JEsd.esd_audio_rate; else amount=(2*44100*(JEsd.ESD_BUF_SIZE+256))/JEsd.esd_audio_rate; } io.writeInt(amount); } break; /* case JEsd.ESD_PROTO_VORBIS_STREAM: { } break; case JEsd.ESD_PROTO_VORBIS_SAMPLE: { } break; */ default: System.out.println("not-implemented: "+Integer.toHexString(reqType)); } } } catch (java.io.IOException e) { //System.out.println(e); } del(this); } static private java.util.Vector pool=new java.util.Vector(); static synchronized void add(Client client){ pool.addElement(client); } static synchronized void del(Client client){ pool.removeElement(client); } } jesd-0.0.7/com/jcraft/jesd/JEsd.java0000644000175000017500000003315007157107020015560 0ustar mjj29mjj29/* JEsd * Copyright (C) 1999 JCraft Inc. * * Written by: 1999 ymnk * * This program 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 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 Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jesd; import java.net.*; import java.io.*; public class JEsd { public static final String version = "0.0.5"; public static final int ESD_MASK_MODE=0x0F00; public static final int ESD_STREAM=0x0000; public static final int ESD_SAMPLE=0x0100; public static final int ESD_ADPCM=0x0200; public static final int ESD_MASK_FUNC=0xF000; public static final int ESD_PLAY=0x1000; /* functions for streams only */ public static final int ESD_MONITOR=0x0000; public static final int ESD_RECORD=0x2000; /* functions for samples only */ public static final int ESD_STOP=0x0000; public static final int ESD_LOOP=0x2000; /* length of the audio buffer size */ public static final int ESD_BUF_SIZE=(4*1024); public static final int ESD_NAME_MAX=128; /* length of the authorization key, octets */ public static final int ESD_KEY_LEN=16; public static final int ESM_ERROR=0; public static final int ESM_ON_STANDBY=1; public static final int ESM_ON_AUTOSTANDBY=2; public static final int ESM_RUNNING=3; public static final int ESD_MASK_CHAN=0x00F0; public static final int ESD_MONO=0x0010; public static final int ESD_STEREO=0x0020; public static final int ESD_MASK_BITS=0x000F; public static final int ESD_BITS8=0x0000; public static final int ESD_BITS16=0x0001; public static final int ESD_DEFAULT_PORT=16001; public static final int ESD_DEFAULT_RATE=44100; // implied on inital client connection static final int ESD_PROTO_CONNECT=0; // pseudo "security" functionality static final int ESD_PROTO_LOCK=1; static final int ESD_PROTO_UNLOCK=2; // stream functionality: play, record, monitor static final int ESD_PROTO_STREAM_PLAY=3; static final int ESD_PROTO_STREAM_REC=4; static final int ESD_PROTO_STREAM_MON=5; // sample functionality: cache, free, play, loop, EOL, kill static final int ESD_PROTO_SAMPLE_CACHE=6; static final int ESD_PROTO_SAMPLE_FREE=7; static final int ESD_PROTO_SAMPLE_PLAY=8; static final int ESD_PROTO_SAMPLE_LOOP=9; static final int ESD_PROTO_SAMPLE_STOP=10; static final int ESD_PROTO_SAMPLE_KILL=11; // free and reclaim /dev/dsp functionality static final int ESD_PROTO_STANDBY=12; static final int ESD_PROTO_RESUME=13; static final int ESD_PROTO_SAMPLE_GETID=14; static final int ESD_PROTO_STREAM_FILT=15; // esd remote management static final int ESD_PROTO_SERVER_INFO=16; static final int ESD_PROTO_ALL_INFO=17; static final int ESD_PROTO_SUBSCRIBE=18; static final int ESD_PROTO_UNSUBSCRIBE=19; // esd remote control static final int ESD_PROTO_STREAM_PAN=20; static final int ESD_PROTO_SAMPLE_PAN=21; // esd status static final int ESD_PROTO_STANDBY_MODE=22; // esd latency static final int ESD_PROTO_LATENCY=23; // Ogg Vorbis support //static final int ESD_PROTO_VORBIS_SAMPLE=24; //static final int ESD_PROTO_VORBIS_STREAM=25; private static final int ESD_ENDIAN_KEY=(('E'<<24)+('N'<<16)+('D'<<8)+('N')); static private byte[] key=null; static int esd_audio_format = ESD_BITS16 | ESD_STEREO; static int esd_audio_rate = ESD_DEFAULT_RATE; private Socket socket=null; private IO io=null; static Class streamPlayerPlugin=null; static void installStreamPlayerPlugin(String plugin){ try{ streamPlayerPlugin=Class.forName(plugin);} catch(Exception e){} } static Class samplePlugin=null; static void installSamplePlugin(String plugin){ try{ samplePlugin=Class.forName(plugin);} catch(Exception e){} } public JEsd() throws JEsdException{ this("localhost", ESD_DEFAULT_PORT); } public JEsd(int port) throws JEsdException{ this("localhost", port); } public JEsd(String host) throws JEsdException{ this(host, ESD_DEFAULT_PORT); } public JEsd(String host, int port) throws JEsdException{ try{ socket=new Socket(host, port); io=new IOMSB(); io.setSocket(socket); send_auth(); } catch(Exception e){ throw new JEsdException(e.toString()); } } private void send_auth() throws IOException{ if(key==null){ key=new byte[ESD_KEY_LEN]; String esd_auth=System.getProperty("user.home",".")+ File.separator+".esd_auth"; try{ FileInputStream fis=new FileInputStream(esd_auth); fis.read(key); fis.close(); } catch(Exception e){ try{ java.util.Random random=new java.util.Random(System.currentTimeMillis()); random.nextBytes(key); FileOutputStream fos=new FileOutputStream(esd_auth); fos.write(key); fos.close(); }catch(Exception ee){ } } } io.writeByte(key); io.writeInt(ESD_ENDIAN_KEY); int reply=io.readInt(); if(reply==0){ //io.close(); } } public int lock(){ return status_op(ESD_PROTO_LOCK); } public int unlock(){ return status_op(ESD_PROTO_UNLOCK); } public int standby(){ return status_op(ESD_PROTO_STANDBY); } public int resume(){ return status_op(ESD_PROTO_RESUME); } private int status_op(int op){ int reply=0; try{ io.writeInt(op); send_auth(); reply=io.readInt(); } catch(Exception e){ } return reply; } public static JEsd play_stream(int format, int rate, String host, String name) throws JEsdException{ return stream_op(ESD_PROTO_STREAM_PLAY, "play_stream", format, rate, host, name); } public static JEsd play_stream_fallback(int format, int rate, String host, String name) throws JEsdException{ try{ return play_stream(format, rate, host, name ); } catch(JEsdException e){ // ?? throw e; } } static private byte[] genName(String name){ byte[] tmp=(name==null ? null : name.getBytes()); if(tmp==null || tmp.length0) buf_size=(buf_size*base_rate)/src_rate; if((src_format&ESD_MASK_BITS)==ESD_BITS16) buf_size*=2; if(!((src_format&ESD_MASK_CHAN)==ESD_MONO)) buf_size *= 2; io.getSocket().setSendBufferSize(buf_size); io.getSocket().setReceiveBufferSize(buf_size); return buf_size; } */ public int sample_cache(int format, int rate, int size, String name){ try{ byte[] tmp=genName(name); io.writeInt(ESD_PROTO_SAMPLE_CACHE); io.writeInt(format); io.writeInt(rate); io.writeInt(size); io.writeByte(tmp, 0, ESD_NAME_MAX); int id=io.readInt(); return id; } catch(Exception e){ } return -1; } public int confirm_sample_cache(){ try{ int id=io.readInt(); return id; } catch(Exception e){ } return -1; } public int sample_getid(String name){ try{ io.writeInt(ESD_PROTO_SAMPLE_GETID); byte[] tmp=genName(name); io.writeByte(tmp, 0, ESD_NAME_MAX); int id=io.readInt(); return id; } catch(Exception e){ } return -1; } public int sample_free(int sample){ return sample_op(ESD_PROTO_SAMPLE_FREE, "sample_free", sample); } public int sample_play(int sample){ return sample_op(ESD_PROTO_SAMPLE_PLAY, "sample_play", sample); } public int sample_loop(int sample){ return sample_op(ESD_PROTO_SAMPLE_LOOP, "sample_loop", sample); } int sample_stop(int sample){ return sample_op(ESD_PROTO_SAMPLE_STOP, "sample_stop", sample); } private int sample_op(int op, String error, int sample){ try{ io.writeInt(op); io.writeInt(sample); int is_ok=io.readInt(); return is_ok; } catch(Exception e){ } return -1; } public int file_cache(String name_prefix, String filename) throws java.io.IOException{ WAVEFile wave=new WAVEFile(filename); int frame_count=wave.getFrameCount(); int in_channels=wave.getChannels(); int in_rate=wave.getRate(); int in_width=wave.getSampleFormatWidth(); int length=wave.getTrackBytes(); int out_bits, out_channels, out_rate; int out_mode=JEsd.ESD_STREAM, out_func=JEsd.ESD_PLAY; if(in_width==8) out_bits=JEsd.ESD_BITS8; else if(in_width==16) out_bits=JEsd.ESD_BITS16; else{ return -1; } int bytes_per_frame=(in_width*in_channels)/8; if(in_channels==1) out_channels=JEsd.ESD_MONO; else if(in_channels==2) out_channels=JEsd.ESD_STEREO; else{ return -1; } int out_format=out_bits|out_channels|out_mode|out_func; out_rate=in_rate; String name=""; if(name_prefix!=null){ if(name_prefix.length()<=ESD_NAME_MAX-2) name=name_prefix; else name=name_prefix.substring(0, ESD_NAME_MAX-3); name=name+":"; } name=name+((filename.length()0){ if(write(buf, frames_read * bytes_per_frame)<=0) return; } } public int write(byte[] array, int size){ return write(array, 0, size); } public int write(byte[] array, int off, int size){ try{ io.writeByte(array, off, size); return size; } catch(Exception e){ } return -1; } public int read(byte[] array, int size){ try{ io.readByte(array, 0, size); return size; } catch(Exception e){ } return -1; } public void close(){ try{ io.close(); } catch(Exception e){} } } jesd-0.0.7/com/jcraft/jesd/Daemon.java0000644000175000017500000000434007134771527016153 0ustar mjj29mjj29/* JEsd * Copyright (C) 1999 JCraft Inc. * * Written by: 1999 ymnk * * This program 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 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 Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jesd; import java.net.*; import java.io.*; public class Daemon extends Thread { static private int port=JEsd.ESD_DEFAULT_PORT; static private String key=null; static Object currentSound=null; private ServerSocket server=null; public Daemon(){ Auth.init(key); try{ server = new ServerSocket(port); } catch (IOException e) { System.out.println(e); } } public void run(){ if(server==null) return; // ?? while(true){ try { Socket socket = server.accept(); Client client = new Client(socket); client.start(); } catch (IOException e) { //System.out.println(e); } } } public void setPort(int p){port=p;} public void setKey(String k){key=k;} static void protoServerInfo(IO io) throws java.io.IOException{ int version=io.readInt(); io.writeInt(100); // version // ?? io.writeInt(44100); // rate io.writeInt(0x1021); // format } static void protoAllInfo(IO io) throws java.io.IOException{ int version=io.readInt(); io.writeInt(100); // version // ?? io.writeInt(44100); // rate io.writeInt(0x1021); // format // player Player.dumpInfo(io); io.writeInt(0); // source id io.writePad(JEsd.ESD_NAME_MAX+16); // sample Sample.dumpInfo(io); io.writeInt(0); // sample id io.writePad(JEsd.ESD_NAME_MAX+20); } public static void main(String args[]) { (new Daemon()).start(); } } jesd-0.0.7/com/jcraft/jesd/IO.java0000644000175000017500000000573007047563741015263 0ustar mjj29mjj29/* JEsd * Copyright (C) 1999 JCraft Inc. * * Written by: 1999 ymnk * * This program 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 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 Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jesd; abstract class IO{ java.io.InputStream in=null; java.io.OutputStream out=null; java.net.Socket socket=null; byte[] ba; byte[] sa; byte[] ia; IO(){ ba=new byte[1]; sa=new byte[2]; ia=new byte[8]; } abstract int readInt() throws java.io.IOException; abstract int readShort() throws java.io.IOException; abstract void writeInt(int val) throws java.io.IOException; abstract void writeShort(int val) throws java.io.IOException; void setInputStream(java.io.InputStream in){this.in=in; } void setOutputStream(java.io.OutputStream out){ this.out=out; } void setSocket(java.net.Socket socket) throws java.io.IOException{ this.socket=socket; setInputStream(socket.getInputStream()); setOutputStream(socket.getOutputStream()); } java.net.Socket getSocket(){ return socket; } int readByte() throws java.io.IOException{ int i=in.read(ba, 0, 1); if(i==-1){ throw new java.io.IOException(); } return ba[0]&0xff; } void readByte(byte[] array) throws java.io.IOException{ readByte(array, 0, array.length); } void readByte(byte[] array, int begin, int length) throws java.io.IOException{ int i=0; while(true){ i=in.read(array, begin, length); if(i==-1){ throw new java.io.IOException(); } length-=i; begin+=i; if(length<=0) return; } } void readPad(int n) throws java.io.IOException{ int i; while (n > 0){ i=in.read(ba, 0, 1); if(i==-1){ throw new java.io.IOException(); } n--; } } void writeByte(byte val) throws java.io.IOException{ ba[0]=val; out.write(ba, 0, 1); } void writeByte(int val) throws java.io.IOException{ writeByte((byte)val); } void writeByte(byte[] array) throws java.io.IOException{ writeByte(array, 0, array.length); } void writeByte(byte[] array, int begin, int length) throws java.io.IOException{ out.write(array, begin, length); } void writePad(int n) throws java.io.IOException{ int i; ba[0]=0; while(0 > >_ ESD_PROTO_MAXI ConstantValue ESD_NAME_MAX ESD_KEY_LENESD_ENDIAN_KEYENDNsocketLjava/net/Socket;ioLcom/jcraft/jesd/IO;swapZrequestpoolLjava/util/Vector;(Ljava/net/Socket;)VCode Exceptionsrun()Vadd(Lcom/jcraft/jesd/Client;)Vdel UZ LM   com/jcraft/jesd/IOMSB NOcom/jcraft/jesd/IOLSB V [\ Zjava/lang/Exception com/jcraft/jesd/StreamPlayerjava/lang/String U U ]\ com/jcraft/jesd/Sample U C com/jcraft/jesd/SamplePlayer U Z Z Z Z Z   C C java/lang/StringBuffernot-implemented:   java/io/IOException ST java/util/Vectorcom/jcraft/jesd/Clientjava/lang/Threadjava/net/SocketgetInputStream()Ljava/io/InputStream;getOutputStream()Ljava/io/OutputStream;java/io/InputStreamread([BII)Icom/jcraft/jesd/Authauth([B)Zcom/jcraft/jesd/IO setSocketwriteInt(I)VclosereadInt()IreadByte([B)V(IILjava/lang/String;)V outputLine$Ljavax/sound/sampled/SourceDataLine;play(Lcom/jcraft/jesd/IO;)V writeByte0(Lcom/jcraft/jesd/Client;IIILjava/lang/String;)Vidfillget(I)Lcom/jcraft/jesd/Sample;(Lcom/jcraft/jesd/Sample;)VloopplayerLcom/jcraft/jesd/SamplePlayer; stop_playingkillfree(Lcom/jcraft/jesd/IO;)Z,(Ljava/lang/String;)Lcom/jcraft/jesd/Sample;com/jcraft/jesd/DaemonprotoServerInfo protoAllInfocom/jcraft/jesd/JEsdesd_audio_formatesd_audio_ratejava/lang/SystemoutLjava/io/PrintStream;append,(Ljava/lang/String;)Ljava/lang/StringBuffer;java/lang/Integer toHexString(I)Ljava/lang/String;toString()Ljava/lang/String;java/io/PrintStreamprintln(Ljava/lang/String;)V addElement(Ljava/lang/Object;)V removeElement(Ljava/lang/Object;)Z @A BCDEFCDGHCDIJCDKLMNOPQRC STUVW*=*++N+::-W=:-W3E*Y * Y * + *  ** :* }X:YZW * 6 :* <@]jw@z!GR* =* >* YY:* * :** =* >* * * =* >* 6* Y*Y: *    * *   * 6:   Y !:"6*  * 6:   Y !:#6*  M* 6:   $ $%6*  * 6:   $ $&6*  * 6:   '*  * (6*  * (6*  * (6*  c* (6*  F* Y):   6 *  * * * +* 6* 6 * 6 *  * 6 * 6 * 6 *  *  , ~!,~-.l6)/.l6,~0.l6 1.l6*  Z23Y4567689;:*:([\W;*<(]\W ;*=W^ZW >Y?;jesd-0.0.7/com/jcraft/jesd/IOLSB.java0000644000175000017500000000320607047563741015620 0ustar mjj29mjj29/* JEsd * Copyright (C) 1999 JCraft Inc. * * Written by: 1999 ymnk * * This program 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 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 Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jesd; final class IOLSB extends IO{ int readInt() throws java.io.IOException{ int i=in.read(ia, 0, 4); if(i==-1){ throw new java.io.IOException(); } i=ia[0]&0xff; i|=((ia[1]&0xff)<<8); i|=((ia[2]&0xff)<<16); i|=((ia[3]&0xff)<<24); return i; } int readShort() throws java.io.IOException{ int i=in.read(sa, 0, 2); if(i==-1){ throw new java.io.IOException(); } i=sa[0]&0xff; i|=((sa[1]&0xff)<<8); return i; } void writeInt(int val) throws java.io.IOException{ ia[0]=(byte)((val) & 0xff); ia[1]=(byte)((val >> 8) & 0xff); ia[2]=(byte)((val >> 16) & 0xff); ia[3]=(byte)((val >> 24) & 0xff); out.write(ia, 0, 4); } void writeShort(int val) throws java.io.IOException{ sa[0]=(byte)((val) & 0xff); sa[1]=(byte)((val >> 8) & 0xff); out.write(sa, 0, 2); } } jesd-0.0.7/com/jcraft/jesd/Daemon.class0000644000175000017500000000263507244161223016330 0ustar mjj29mjj29-_ 0 1 2 345 6 78 9: ;< => ? @ AB ACD DE AF GEH 0 IJportIkeyLjava/lang/String; currentSoundLjava/lang/Object;serverLjava/net/ServerSocket;()VCoderunsetPort(I)VsetKey(Ljava/lang/String;)VprotoServerInfo(Lcom/jcraft/jesd/IO;)V Exceptions protoAllInfomain([Ljava/lang/String;)V !"  K L(java/net/ServerSocket  !&java/io/IOExceptionM NOP QR STcom/jcraft/jesd/Client !U V"W XY Z&[ \* ]&^com/jcraft/jesd/Daemon java/lang/Threadcom/jcraft/jesd/Authinitjava/lang/SystemoutLjava/io/PrintStream;java/io/PrintStreamprintln(Ljava/lang/Object;)Vaccept()Ljava/net/Socket;(Ljava/net/Socket;)Vstartcom/jcraft/jesd/IOreadInt()IwriteIntcom/jcraft/jesd/PlayerdumpInfowritePadcom/jcraft/jesd/Sample!   !"#=)***Y L +  $"#8$** L Y+ M,L %&#'(#+)*#%*<*d**!+,*#E9*<*d**!******+ -.# Y/"#>jesd-0.0.7/com/jcraft/jesd/IOMSB.java0000644000175000017500000000324607047563741015625 0ustar mjj29mjj29/* JEsd * Copyright (C) 1999 JCraft Inc. * * Written by: 1999 ymnk * * This program 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 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 Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jesd; final class IOMSB extends IO { int readInt() throws java.io.IOException{ int i=in.read(ia, 0, 4); if(i==-1){ throw new java.io.IOException(); } i=ia[0]&0xff; i=((i<<8)&0xffff)|(ia[1]&0xff); i=((i<<8)&0xffffff)|(ia[2]&0xff); i=(i<<8)|(ia[3]&0xff); return i; } int readShort() throws java.io.IOException{ int i=in.read(sa, 0, 2); if(i==-1){ throw new java.io.IOException(); } i=sa[0]&0xff; i=((i<<8)&0xffff)|(sa[1]&0xff); return i; } void writeInt(int val) throws java.io.IOException{ ia[0]=(byte)((val >> 24) & 0xff); ia[1]=(byte)((val >> 16) & 0xff); ia[2]=(byte)((val >> 8) & 0xff); ia[3]=(byte)((val) & 0xff); out.write(ia, 0, 4); } void writeShort(int val) throws java.io.IOException{ sa[0]=(byte)((val >> 8) & 0xff); sa[1]=(byte)((val) & 0xff); out.write(sa, 0, 2); } } jesd-0.0.7/com/jcraft/jesd/DaemonWithVorbis.class0000644000175000017500000000313507244161223020345 0ustar mjj29mjj29-k 4 5 6 789 : ;< => ?@ AB C D EF EGD HI EJ KIL 4M NOP NQ RSportIkeyLjava/lang/String; currentSoundLjava/lang/Object;serverLjava/net/ServerSocket;()VCoderunsetPort(I)VsetKey(Ljava/lang/String;)VprotoServerInfo(Lcom/jcraft/jesd/IO;)V Exceptions protoAllInfomain([Ljava/lang/String;)V %& #$  T U,java/net/ServerSocket  %*java/io/IOExceptionV WXY Z[ \]com/jcraft/jesd/Client %^ _&` ab c*d e. f*g com/jcraft/jesd/DaemonWithVorbis#com.jcraft.jesd.vorbis.StreamPlayerh i,com.jcraft.jesd.vorbis.Sample j, !"java/lang/Threadcom/jcraft/jesd/Authinitjava/lang/SystemoutLjava/io/PrintStream;java/io/PrintStreamprintln(Ljava/lang/Object;)Vaccept()Ljava/net/Socket;(Ljava/net/Socket;)Vstartcom/jcraft/jesd/IOreadInt()IwriteIntcom/jcraft/jesd/PlayerdumpInfowritePadcom/jcraft/jesd/Samplecom/jcraft/jesd/JEsdinstallStreamPlayerPlugininstallSamplePlugin!   !"#$%&'=)***Y L +  (&'8$** L Y+ M,L )*'+,'+-.'%*<*d**!/0.'E9*<*d**!******/ 12' Y3&'%>jesd-0.0.7/com/jcraft/jesd/IOLSB.class0000644000175000017500000000153507244161223015773 0ustar mjj29mjj29-/         !()VCodereadInt()I Exceptions readShortwriteInt(I)V writeShort "# $%& '(java/io/IOException )% *+, -.com/jcraft/jesd/IOLSBcom/jcraft/jesd/IOinLjava/io/InputStream;ia[Bjava/io/InputStreamread([BII)IsaoutLjava/io/OutputStream;java/io/OutputStreamwrite([BII)V0  *dX**< Y*3~<*3~x<*3~x<*3~x<D8**< Y*3~<*3~x<SG*~T*z~T*z~T*z~T** 5)*~T*z~T** jesd-0.0.7/com/jcraft/jesd/JEsdException.java0000644000175000017500000000172007047563741017453 0ustar mjj29mjj29/* JEsd * Copyright (C) 1999 JCraft Inc. * * Written by: 1999 ymnk * * This program 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 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 Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jesd; public class JEsdException extends Exception{ public JEsdException(){ super(); } public JEsdException (String s){ super("JEsd: "+s); } } jesd-0.0.7/com/jcraft/jesd/IOMSB.class0000644000175000017500000000156007244161223015772 0ustar mjj29mjj29-1        !"#()VCodereadInt()I Exceptions readShortwriteInt(I)V writeShort  $% &'( )*java/io/IOException +' ,-. /0com/jcraft/jesd/IOMSBcom/jcraft/jesd/IOinLjava/io/InputStream;ia[Bjava/io/InputStreamread([BII)IsaoutLjava/io/OutputStream;java/io/OutputStreamwrite([BII)V0 *j^**< Y*3~<x~*3~<x~*3~<x*3~<G;** < Y* 3~<x~* 3~<SG*z~T*z~T*z~T*~T* * 5)* z~T* ~T* *  jesd-0.0.7/com/jcraft/jesd/Player.java0000644000175000017500000000363307047563741016210 0ustar mjj29mjj29/* JEsd * Copyright (C) 1999 JCraft Inc. * * Written by: 1999 ymnk * * This program 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 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 Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jesd; import java.util.Vector; abstract class Player{ int id=0; static private Vector pool=new Vector(); static protected synchronized void add(Player p){ pool.addElement(p); } static protected synchronized void del(Player p){ pool.removeElement(p); } static private int _id=1; static synchronized int getId(){ return _id++; } static synchronized void resetId(){ _id=1; } static synchronized Player get(int id){ int size=pool.size(); Player p; for(int i=0; iversionLjava/lang/String; ConstantValue? ESD_MASK_MODEI ESD_STREAM ESD_SAMPLE ESD_ADPCM ESD_MASK_FUNCESD_PLAY ESD_MONITOR ESD_RECORD ESD_STOPESD_LOOP ESD_BUF_SIZE ESD_NAME_MAX ESD_KEY_LEN ESM_ERRORESM_ON_STANDBYESM_ON_AUTOSTANDBY ESM_RUNNING ESD_MASK_CHANESD_MONO ESD_STEREO  ESD_MASK_BITS ESD_BITS8 ESD_BITS16ESD_DEFAULT_PORT>ESD_DEFAULT_RATEESD_PROTO_CONNECTESD_PROTO_LOCKESD_PROTO_UNLOCKESD_PROTO_STREAM_PLAYESD_PROTO_STREAM_RECESD_PROTO_STREAM_MONESD_PROTO_SAMPLE_CACHEESD_PROTO_SAMPLE_FREEESD_PROTO_SAMPLE_PLAYESD_PROTO_SAMPLE_LOOP ESD_PROTO_SAMPLE_STOP ESD_PROTO_SAMPLE_KILL ESD_PROTO_STANDBY ESD_PROTO_RESUME ESD_PROTO_SAMPLE_GETIDESD_PROTO_STREAM_FILTESD_PROTO_SERVER_INFOESD_PROTO_ALL_INFOESD_PROTO_SUBSCRIBEESD_PROTO_UNSUBSCRIBEESD_PROTO_STREAM_PANESD_PROTO_SAMPLE_PANESD_PROTO_STANDBY_MODEESD_PROTO_LATENCYESD_ENDIAN_KEYkey[Besd_audio_formatesd_audio_ratesocketLjava/net/Socket;ioLcom/jcraft/jesd/IO;streamPlayerPluginLjava/lang/Class; samplePlugininstallStreamPlayerPlugin(Ljava/lang/String;)VCodeinstallSamplePlugin()V Exceptions(I)V(Ljava/lang/String;I)V send_auth@lock()Iunlockstandbyresume status_op(I)I play_stream>(IILjava/lang/String;Ljava/lang/String;)Lcom/jcraft/jesd/JEsd;play_stream_fallbackgenName(Ljava/lang/String;)[Bmonitor_stream filter_stream record_streamrecord_stream_fallback stream_opQ(ILjava/lang/String;IILjava/lang/String;Ljava/lang/String;)Lcom/jcraft/jesd/JEsd; sample_cache(IIILjava/lang/String;)Iconfirm_sample_cache sample_getid(Ljava/lang/String;)I sample_free sample_play sample_loop sample_stop sample_op(ILjava/lang/String;I)I file_cache'(Ljava/lang/String;Ljava/lang/String;)I play_file((Ljava/lang/String;Ljava/lang/String;Z)V send_file(Lcom/jcraft/jesd/WAVEFile;I)Vwrite([BI)I([BII)IreadcloseA BC java/lang/Exception  localhost java/net/Socketcom/jcraft/jesd/IOMSBD EF com/jcraft/jesd/JEsdExceptionG HI java/lang/StringBuffer user.home.J KL MNO P\ .esd_authjava/io/FileInputStream Q java/util/Random RS T UVjava/io/FileOutputStream V WV X Y Z [\ ]^ com/jcraft/jesd/JEsd W_ com/jcraft/jesd/WAVEFile ` a b c d e fg: hij kl m n_ ` `java/lang/Object0.0.5java/io/IOExceptionjava/lang/ClassforName%(Ljava/lang/String;)Ljava/lang/Class;com/jcraft/jesd/IO setSocket(Ljava/net/Socket;)Vjava/lang/ThrowabletoString()Ljava/lang/String;java/lang/System getProperty8(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;append,(Ljava/lang/String;)Ljava/lang/StringBuffer; java/io/File separator([B)IcurrentTimeMillis()J(J)V nextBytes([B)V writeBytewriteIntreadIntjava/lang/StringgetBytes()[B arraycopy*(Ljava/lang/Object;ILjava/lang/Object;II)V([BII)V getFrameCount getChannelsgetRategetSampleFormatWidth getTrackByteslength substring(II)Ljava/lang/String;outLjava/io/PrintStream;java/io/PrintStreamprintln(Ljava/lang/Object;)V readFramereadByte!6Z:[\]^_`]ab`]cd`]ef`]gh`]ij`]kl`]cm`]no`]cp`]nq`]kr`]st`]uv`]cw`]xy`]z{`]|}`]~`]u`]`]`]c`]x`]`]X`]c`]x`]z`]|`]`]`]`]`]`]`]`]`]`]`]`]`]u`]`]`]`]`]`]`]`]* ``$  *L   *L  *>* *+>ZF*** * Y+ * Y * **NY-58pYLY+M,W, 1M!Y"#N-$%Y+&:'(N* )* *+* ,<-BEFor*-*-* -* -0=* +** ,=N  .,-/ ! ,-0: C7**1L+ +M++,+2+T,L+  3,-/  3,-/  4,-/ %,-5::  dP6Y7:8: + + + 9:Y ;>YE8:* +* +* +* +* 9* ,6:AA! * ,<L ;'* ++8M* ,9* ,>M$$ *:; *<; * =; * >;4 * +* +* ,6:'?Y,@N-A6-B6-C6-D6-E66 6  6  6 hl6 6   6     66 F:+1+G~ +: +}H:YI:Y,GGd,,GddH:* J6*-K-L*M6 9%?Y+@N-A6-B6-C6-D66 6  6 6hl6  6   6    66 F:*1*G~ *: *}H:YI:Y+GGd++GddH:: N: +0::OP- KQ  =1Nl666*-hR+-SY6*+T$* +9: #* +UN   * VL #!WXYjesd-0.0.7/com/jcraft/jesd/Sample.java0000644000175000017500000001322407222345457016167 0ustar mjj29mjj29/* JEsd * Copyright (C) 1999 JCraft Inc. * * Written by: 1999 ymnk * * This program 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 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 Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jesd; //import javax.media.sound.midi.*; //import javax.media.sound.sampled.*; import javax.sound.midi.*; import javax.sound.sampled.*; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; class Sample { Client parent; // the client that spawned sample int format; // magic int with the format info int rate; // sample rate int left_vol_scale; // volume scaling int right_vol_scale; int id; // id number byte[] buffer; // buffer to hold sound data int size; int sample_length; // total buffer length int cached_length; // amount of data cached so far int ref_count; // track players for clean deletion boolean erase_when_done; // track uncache requests String name; // name of sample for remote control Clip clip = null; SamplePlayer player = null; Sample(Client parent, int format, int rate, int size, String name){ this.parent=parent; this.format=format; this.rate=rate; this.size=size; this.name=name; id=getId(); add(this); } void free(){ if(player!=null) player.kill(); if(clip!=null)clip.close(); clip=null; name=null; buffer=null; del(this); } static private java.util.Vector pool=new java.util.Vector(); static private int _id=1; static synchronized int getId(){ return _id++; } static synchronized void resetId(){ _id=1; } static synchronized void add(Sample sample){ pool.addElement(sample); } static synchronized void del(Sample sample){ pool.removeElement(sample); } static synchronized Sample get(int id){ int size=pool.size(); Sample sample; for(int i=0; i0) outputLine.write(buffer, 0, i/*/frameSizeInBytes*/); else break; } if(outputLine!=null){ outputLine.drain(); outputLine.stop(); outputLine.close(); outputLine.removeLineListener(this); } if(io!=null){ try{io.close();}catch(Exception ee){} } } catch(Exception e){} del(this); } void terminate(){ if(outputLine!=null){ SourceDataLine tmp=outputLine; outputLine=null; tmp.stop(); tmp.close(); tmp.removeLineListener(this); } del(this); } public void update(LineEvent event) { //System.out.println("update: "+event); } // public void meta(MetaEvent event) { // //System.out.println("meta: "+event); // } } jesd-0.0.7/com/jcraft/jesd/JEsdException.class0000644000175000017500000000060207244161223017621 0ustar mjj29mjj29-     ()VCode(Ljava/lang/String;)V java/lang/StringBufferJEsd:   com/jcraft/jesd/JEsdExceptionjava/lang/Exceptionappend,(Ljava/lang/String;)Ljava/lang/StringBuffer;toString()Ljava/lang/String;!   *  $*Y+jesd-0.0.7/com/jcraft/jesd/Player.class0000644000175000017500000000243207244161223016354 0ustar mjj29mjj29-Y , - . / 0 12 34 56 7 89 5: ; < = > ? @A ?BidIpoolLjava/util/Vector;_idadd(Lcom/jcraft/jesd/Player;)VCodedelgetId()IresetId()Vget(I)Lcom/jcraft/jesd/Player;dumpInfo(Lcom/jcraft/jesd/IO;)V ExceptionsC  DE FG  H! IJcom/jcraft/jesd/Player com/jcraft/jesd/StreamPlayerK LM NOP QR ST U V W X *# !java/util/Vectorjava/lang/Objectjava/io/IOException addElement(Ljava/lang/Object;)V removeElement(Ljava/lang/Object;)Zsize elementAt(I)Ljava/lang/Object;com/jcraft/jesd/IOwriteInt(I)VnameLjava/lang/String;java/lang/StringgetBytes()[B writeByte([B)Vrateleft_vol_scaleright_vol_scaleformat   ,*, *W( ! Y`("#($%7+<>M,,(&'nb<6QM, ;, N*- *- *- *- *- *- ()*#***+#Yjesd-0.0.7/com/jcraft/jesd/WAVEFile.java0000644000175000017500000001260107047563741016311 0ustar mjj29mjj29/* JEsd * Copyright (C) 1999 JCraft Inc. * * Written by: 1999 ymnk * * This program 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 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 Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jesd; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.io.FileInputStream; import java.io.IOException; public class WAVEFile{ private WAVEHeader wheader; InputStream is=null; public WAVEFile(String name) throws IOException{ wheader=WAVEHeader.parse(name); try{ is=new FileInputStream(name); is.skip(wheader.getHeader().length); } catch(Exception e){ } } WAVEFile(int format, int rate, int datasize) throws IOException{ wheader=new WAVEHeader(format, rate, datasize); } public byte[] getHeader(){ return wheader.getHeader(); } public int readFrame(byte[] buf, int fcount){ int i; try{ i=is.read(buf, 0, fcount*getFrameSize()); } catch(Exception e){ return -1; } return i/getFrameSize(); } public int getFrameCount(){ return wheader.datasize/getFrameSize(); } public int getFrameSize(){ return wheader.channels*(wheader.bits/8); } public int getChannels(){ return wheader.channels; } public int getRate(){ return wheader.rate; } public int getSampleFormatWidth(){ return wheader.bits; } public int getTrackBytes(){ return wheader.datasize; } public void close() throws IOException{ is.close(); } } class WAVEHeader{ static final int HEADERSIZE=44; private static byte[] RIFF="RIFF".getBytes(); private static byte[] WAVE="WAVE".getBytes(); private static byte[] fmt_="fmt ".getBytes(); private static byte[] data="data".getBytes(); int format, rate, datasize; int channels=1; int bits=8; byte[] header=null; WAVEHeader(int format, int rate, int datasize){ this.format=format; this.rate=rate; this.datasize=datasize; } static WAVEHeader parse(String name){ try{ int format=0; int rate=0; int datasize=0; int channels=0; int bps=0; // averate byte per second int balign=0; // block align int bits=0; // 8/16 FileInputStream fis=new FileInputStream(name); byte[] tmp=new byte[4]; fis.read(tmp, 0, 4); IO io=null; // if(riff[0]=='R') io=new IOLSB(); else io=new IOMSB(); io=new IOLSB(); io.setInputStream(fis); int header_data_size=io.readInt(); int len=header_data_size; io.readByte(tmp, 0, 4); len-=4; // WAVE while(len>0){ io.readByte(tmp, 0, 4); len-=4; // chunk id; String s=new String(tmp); int size=io.readInt(); len-=4; // chunk size if(s.equals("fmt ")){ int tag=io.readShort(); // format tag size-=2; len-=2; channels=io.readShort(); // channel count rate=io.readInt(); // sample rate bps=io.readInt(); // averate byte per second balign=io.readShort(); // block align size-=12; len-=12; if(tag==1){ // WAVE_FORMAT_PCM bits=io.readShort(); // bits per sample size-=2; len-=2; } continue; } if(s.equals("data")){ datasize=size; // size len-=datasize; continue; } //System.out.println("unknown chunk: "+s); io.readPad(size); len-=size; } try{ io.close(); }catch(Exception e){}; //fis.close(); WAVEHeader wh=new WAVEHeader(format, rate, datasize); wh.channels=channels; wh.bits=bits; fis=new FileInputStream(name); wh.header=new byte[header_data_size-datasize]; fis.read(wh.header, 0, wh.header.length); fis.close(); return wh; } catch(Exception e){ return null;} } byte[] getHeader(){ if(header!=null) return header; if((format & JEsd.ESD_MASK_CHAN)==JEsd.ESD_STEREO) channels=2; if((format & JEsd.ESD_MASK_BITS)==JEsd.ESD_BITS16) bits=16; try{ ByteArrayOutputStream baos=new ByteArrayOutputStream(HEADERSIZE); IOLSB io=new IOLSB(); io.setOutputStream(baos); io.writeByte(RIFF); io.writeInt(datasize+(HEADERSIZE-8)); io.writeByte(WAVE); io.writeByte(fmt_); // format chunk io.writeInt(16); // size io.writeShort(1); // format tag io.writeShort(channels); // channel count io.writeInt(rate); // sample rate io.writeInt(rate*(bits/8)); // averate byte per second io.writeShort(1); // block align io.writeShort(bits); // bits per sample io.writeByte(data); // data chunk io.writeInt(datasize); // size header=baos.toByteArray(); return header; } catch(Exception e){ //System.out.println(e); } return null; } } jesd-0.0.7/com/jcraft/jesd/Sample.class0000644000175000017500000001017607244161223016345 0ustar mjj29mjj29- wxyz {| } B~               @ @ @ @ w ~  #   ' '         7  > @~parentLcom/jcraft/jesd/Client;formatIrateleft_vol_scaleright_vol_scaleidbuffer[Bsize sample_length cached_length ref_counterase_when_doneZnameLjava/lang/String;clipLjavax/sound/sampled/Clip;playerLcom/jcraft/jesd/SamplePlayer;poolLjava/util/Vector;_idclass$javax$sound$sampled$ClipLjava/lang/Class; Synthetic0(Lcom/jcraft/jesd/Client;IIILjava/lang/String;)VCodefree()VgetId()IresetIdadd(Lcom/jcraft/jesd/Sample;)Vdelget(I)Lcom/jcraft/jesd/Sample;,(Ljava/lang/String;)Lcom/jcraft/jesd/Sample;fill(Lcom/jcraft/jesd/IO;)VdumpInfo ExceptionsmkClip()Zclass$%(Ljava/lang/String;)Ljava/lang/Class; u java/lang/ClassNotFoundExceptionjava/lang/NoClassDefFoundError _ _c UV WX CD EF GF MF ST de JF gh c c KL ih [F YZ Me com/jcraft/jesd/Sample  ] com/jcraft/jesd/SamplePluginjava/io/ByteArrayOutputStream java/io/ByteArrayInputStream _ com/jcraft/jesd/WAVEFile _  com/jcraft/jesd/PluginException rsjava/lang/Exception HF IF NF  !javax/sound/sampled/DataLine$InfoInfo InnerClasses \]javax.sound.sampled.Clip tu _ javax/sound/sampled/Clip java/util/Vectorjava/lang/Objectjava/io/IOExceptionjava/lang/ClassforNamejava/lang/Throwable getMessage()Ljava/lang/String;(Ljava/lang/String;)Vcom/jcraft/jesd/SamplePlayerkilljavax/sound/sampled/Lineclose addElement(Ljava/lang/Object;)V removeElement(Ljava/lang/Object;)Z elementAt(I)Ljava/lang/Object;java/lang/Stringequalscom/jcraft/jesd/JEsd samplePlugin newInstance()Ljava/lang/Object;com/jcraft/jesd/IOreadByte([BII)V([B)Vplay.(Ljava/io/OutputStream;Ljava/io/InputStream;)V(III)V getHeader()[Bjava/lang/System arraycopy*(Ljava/lang/Object;ILjava/lang/Object;II)V toByteArraywriteInt(I)VgetBytes writeBytejavax/sound/sampled/AudioSystemgetAudioInputStream=(Ljava/io/InputStream;)Ljavax/sound/sampled/AudioInputStream;$javax/sound/sampled/AudioInputStream getFormat#()Ljavax/sound/sampled/AudioFormat;javax/sound/sampled/DataLinegetFrameLength()J6(Ljava/lang/Class;Ljavax/sound/sampled/AudioFormat;I)VgetLine;(Ljavax/sound/sampled/Line$Info;)Ljavax/sound/sampled/Line;open)(Ljavax/sound/sampled/AudioInputStream;)Vjavax/sound/sampled/Line$Info BCDEFGFHFIFJFKLMFNFOFPFQRSTUVWX YZ [F\]^ _`aA5****+ * * * * **bca>2* ** *** **(dea Y`(fca(gha*(iha *W(jka7+<>M,,(jla:.<>M, *,mna>"MղN: Y!:* :+* "#Y$:-%*& 'Y* * * ()M*,* `,*,*+*,* *:'Y* * * ()M*,* `,*,**,* *A'Y* * * ()M*,* `,*,*+*,* "*-WM, .(onag[<>LM*,/*, 01*, /*,2/*,3/*, /*,4/pqrsahT#Y*$5L+6M7Y89:Y88,+;*+?LLO.tua&*LY+^vca@YA7 jesd-0.0.7/com/jcraft/jesd/vorbis/0000755000175000017500000000000007222345276015404 5ustar mjj29mjj29jesd-0.0.7/com/jcraft/jesd/vorbis/Sample.java0000644000175000017500000001452407157107403017471 0ustar mjj29mjj29/* JEsd * Copyright (C) 1999 JCraft Inc. * * Written by: 1999 ymnk * * This program 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 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 Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jesd.vorbis; import com.jcraft.jesd.SamplePlugin; import com.jcraft.jesd.PluginException; import com.jcraft.jorbis.*; import java.util.*; import java.net.*; import java.io.*; public class Sample implements SamplePlugin{ InputStream bitStream; static int convsize=4096*2; byte[] convbuffer=null; SyncState oy; StreamState os; Page og; Packet op; Info vi; Comment vc; DspState vd; Block vb; byte[] buffer=null; int bytes=0; int format; int rate=0; int left_vol_scale=100; int right_vol_scale=100; java.io.OutputStream outputLine=null; int frameSizeInBytes; int bufferLengthInBytes; public void play(java.io.OutputStream outputLine, java.io.InputStream in) throws PluginException{ this.outputLine=outputLine; bitStream=in; int eos=0; oy=new SyncState(); og=new Page(); int index=oy.buffer(4096); buffer=oy.data; try{ bytes=bitStream.read(buffer, index, 4096); } catch(Exception e){ bye(buffer, bytes, 4096); } oy.wrote(bytes); if(oy.pageout(og)!=1){ //if(bytes<4096)break; //System.err.println("Input does not appear to be an Ogg bitstream."); bye(buffer, bytes, 4096); } init_jorbis(); os.init(og.serialno()); vi.init(); vc.init(); if(os.pagein(og)<0){ // error; stream version mismatch perhaps //System.err.println("Error reading first page of Ogg bitstream data."); //bye(buffer, bytes, 4096); return; } if(os.packetout(op)!=1){ // no page? must not be vorbis //System.err.println("Error reading initial header packet."); //bye(buffer, bytes, 4096); return; } if(op.synthesis_headerin(vi,vc)<0){ // error case; not a vorbis header //System.err.println("This Ogg bitstream does not contain Vorbis audio data."); //bye(buffer, bytes, 4096); return; } int i=0; while(i<2){ while(i<2){ int result=oy.pageout(og); if(result==0) break; // Need more data if(result==1){ os.pagein(og); while(i<2){ result=os.packetout(op); if(result==0)break; if(result==-1){ //System.err.println("Corrupt secondary header. Exiting."); return; } op.synthesis_headerin(vi,vc); i++; } } } index=oy.buffer(4096); buffer=oy.data; try{ bytes=bitStream.read(buffer, index, 4096); } catch(Exception e){ //System.err.println(e); return; } if(bytes==0 && i<2){ //System.err.println("End of file before finding all Vorbis headers!"); return; } oy.wrote(bytes); } convsize=4096/vi.channels; vd.synthesis_init(vi); vb.init(vd); double[][][] _pcm=new double[1][][]; int[] _index=new int[vi.channels]; //getOutputLine(vi.rate); while(eos==0){ while(eos==0){ int result=oy.pageout(og); if(result==0){ break; // need more data } if(result==-1){ // missing or corrupt data at this page position //System.err.println("Corrupt or missing data in bitstream; continuing..."); } else{ os.pagein(og); while(true){ result=os.packetout(op); if(result==0){ break; // need more data } if(result==-1){ // missing or corrupt data at this page position // no reason to complain; already complained above //System.err.println("Corrupt or missing data in bitstream; continuing...2"); } else{ // we have a packet. Decode it int samples; if(vb.synthesis(op)==0){ // test for success! vd.synthesis_blockin(vb); } while((samples=vd.synthesis_pcmout(_pcm, _index))>0){ //System.out.println("samples: "+samples+", "+_pcm[0]); double[][] pcm=_pcm[0]; boolean clipflag=false; int bout=(samples32767){ val=32767; clipflag=true; } if(val<-32768){ val=-32768; clipflag=true; } if(val<0) val=val|0x8000; convbuffer[ptr]=(byte)(val); convbuffer[ptr+1]=(byte)(val>>>8); ptr+=2*(vi.channels); } } try{ outputLine.write(convbuffer, 0, 2*vi.channels*bout); } catch(Exception e){}; vd.synthesis_read(bout); } } } if(og.eos()!=0)eos=1; } } if(eos==0){ index=oy.buffer(4096); buffer=oy.data; try{ bytes=bitStream.read(buffer,index,4096); } catch(Exception e){ System.err.println(e); return; } if(bytes==-1) break; oy.wrote(bytes); if(bytes==0)eos=1; } } os.clear(); vb.clear(); vd.clear(); vi.clear(); oy.clear(); } void init_jorbis(){ //convbuffer=new byte[convsize]; convbuffer=new byte[4096*2]; //oy=new SyncState(); //og=new Page(); os=new StreamState(); op=new Packet(); vi=new Info(); vc=new Comment(); vd=new DspState(); vb=new Block(vd); buffer=null; bytes=0; oy.init(); } private void bye(byte[] foo, int len, int max) throws PluginException{ if(len0){ //System.out.println("samples: "+samples+", "+_pcm[0]); double[][] pcm=_pcm[0]; boolean clipflag=false; int bout=(samples32767){ val=32767; clipflag=true; } if(val<-32768){ val=-32768; clipflag=true; } if(val<0) val=val|0x8000; convbuffer[ptr]=(byte)(val); convbuffer[ptr+1]=(byte)(val>>>8); ptr+=2*(vi.channels); } } outputLine.write(convbuffer, 0, 2*vi.channels*bout); vd.synthesis_read(bout); } } } if(og.eos()!=0)eos=1; } } if(eos==0){ index=oy.buffer(4096); buffer=oy.data; try{ bytes=bitStream.read(buffer,index,4096); } catch(Exception e){ System.err.println(e); return; } if(bytes==-1) break; oy.wrote(bytes); if(bytes==0)eos=1; } } os.clear(); vb.clear(); vd.clear(); vi.clear(); oy.clear(); } void init_jorbis(){ //convbuffer=new byte[convsize]; convbuffer=new byte[4096*2]; //oy=new SyncState(); //og=new Page(); os=new StreamState(); op=new Packet(); vi=new Info(); vc=new Comment(); vd=new DspState(); vb=new Block(vd); buffer=null; bytes=0; oy.init(); } private void bye(byte[] foo, int len, int max) throws PluginException{ if(len J @ : J : < > J J B J D D B@ B B : D B >  :w <w >w @w Bw D  H bitStreamLjava/io/InputStream;convsizeI convbuffer[BoyLcom/jcraft/jorbis/SyncState;osLcom/jcraft/jorbis/StreamState;ogLcom/jcraft/jorbis/Page;opLcom/jcraft/jorbis/Packet;viLcom/jcraft/jorbis/Info;vcLcom/jcraft/jorbis/Comment;vdLcom/jcraft/jorbis/DspState;vbLcom/jcraft/jorbis/Block;bufferbytesformatrateleft_vol_scaleright_vol_scale outputLineLjava/io/OutputStream;frameSizeInBytesbufferLengthInBytes()VCodeplay.(Ljava/io/OutputStream;Ljava/io/InputStream;)V Exceptions init_jorbisbye([BII)V mn QR cR dP fP gP hP ij MNcom/jcraft/jorbis/SyncState STcom/jcraft/jorbis/Page WX c R java/lang/Exception tu sn UV [\ n ]^ YZ P OP _` ab [[D  u   n com/jcraft/jorbis/StreamStatecom/jcraft/jorbis/Packetcom/jcraft/jorbis/Infocom/jcraft/jorbis/Commentcom/jcraft/jorbis/DspStatecom/jcraft/jorbis/Block m com/jcraft/jesd/PluginException mcom/jcraft/jesd/vorbis/Samplejava/lang/Objectcom/jcraft/jesd/SamplePlugin(I)Idatajava/io/InputStreamread([BII)Iwrotepageout(Lcom/jcraft/jorbis/Page;)Iserialno()Iinit(I)Vpagein packetout(Lcom/jcraft/jorbis/Packet;)Isynthesis_headerin6(Lcom/jcraft/jorbis/Info;Lcom/jcraft/jorbis/Comment;)Ichannelssynthesis_init(Lcom/jcraft/jorbis/Info;)I(Lcom/jcraft/jorbis/DspState;)V synthesissynthesis_blockin(Lcom/jcraft/jorbis/Block;)Ijava/io/OutputStreamwritesynthesis_readsynthesis_pcmout ([[[D[I)Ieosjava/lang/SystemerrLjava/io/PrintStream;java/io/PrintStreamprintln(Ljava/lang/Object;)Vclear arraycopy*(Ljava/lang/Object;ILjava/lang/Object;II)V([B)V!JKLMNOPQRSTUVWXYZ[\]^_`abcRdPePfPgPhPijkPlPmno6*******d*d*pqo*+*, >* Y * Y* 6** ** *:**** *W* ************* !* **"6b* *6SG**W2** !6#* **"W* 6** ** *:* * *W*#l$*%*&W*'*%():*# :ȧd* *6SF**W** !6*'* **%*'+W2: 6  $ $6 6 6h6 .66k 2`1,k6 66  66  .6* T* `|T *#h`6  *#r+**#h h/:*% 0W*%1Y6 *2>\* 6** ** *:34** *W*>*5*'6W*%7*8* 9W9MPbvy  XlorHsnoma* *:Y;*Y?*@YA*BYC%*DY*%E'*** Ftuo+:+GLHY+IrHvno $jesd-0.0.7/com/jcraft/jesd/vorbis/StreamPlayer.class0000644000175000017500000000736007157111503021040 0ustar mjj29mjj29- Kw Jx Jy Jz J{ J| J} J~ J w J w J  J J J : J > J @ : J : < > J J B J D D B@ B B : D B >  :w <w >w @w Bw D  H bitStreamLjava/io/InputStream;convsizeI convbuffer[BoyLcom/jcraft/jorbis/SyncState;osLcom/jcraft/jorbis/StreamState;ogLcom/jcraft/jorbis/Page;opLcom/jcraft/jorbis/Packet;viLcom/jcraft/jorbis/Info;vcLcom/jcraft/jorbis/Comment;vdLcom/jcraft/jorbis/DspState;vbLcom/jcraft/jorbis/Block;bufferbytesformatrateleft_vol_scaleright_vol_scale outputLine$Ljavax/sound/sampled/SourceDataLine;frameSizeInBytesbufferLengthInBytes()VCodeplay<(Ljavax/sound/sampled/SourceDataLine;Ljava/io/InputStream;)V Exceptions init_jorbisbye([BII)V mn QR cR dP fP gP hP ij MNcom/jcraft/jorbis/SyncState STcom/jcraft/jorbis/Page WX c R java/lang/Exception tu sn UV [\ n ]^ YZ P OP _` ab [[D    n com/jcraft/jorbis/StreamStatecom/jcraft/jorbis/Packetcom/jcraft/jorbis/Infocom/jcraft/jorbis/Commentcom/jcraft/jorbis/DspStatecom/jcraft/jorbis/Block m com/jcraft/jesd/PluginException m#com/jcraft/jesd/vorbis/StreamPlayerjava/lang/Object"com/jcraft/jesd/StreamPlayerPlugin(I)Idatajava/io/InputStreamread([BII)Iwrotepageout(Lcom/jcraft/jorbis/Page;)Iserialno()Iinit(I)Vpagein packetout(Lcom/jcraft/jorbis/Packet;)Isynthesis_headerin6(Lcom/jcraft/jorbis/Info;Lcom/jcraft/jorbis/Comment;)Ichannelssynthesis_init(Lcom/jcraft/jorbis/Info;)I(Lcom/jcraft/jorbis/DspState;)V synthesissynthesis_blockin(Lcom/jcraft/jorbis/Block;)I"javax/sound/sampled/SourceDataLinewritesynthesis_readsynthesis_pcmout ([[[D[I)Ieosjava/lang/SystemerrLjava/io/PrintStream;java/io/PrintStreamprintln(Ljava/lang/Object;)Vclear arraycopy*(Ljava/lang/Object;ILjava/lang/Object;II)V([B)V!JKLMNOPQRSTUVWXYZ[\]^_`abcRdPePfPgPhPijkPlPmno6*******d*d*pqo*+*, >* Y * Y* 6** ** *:**** *W* ************* !* **"6b* *6SG**W2** !6#* **"W* 6** ** *:* * *W*#l$*%*&W*'*%():*# :Ƨb* *6QD**W** !6*'* **%*'+W2: 6  $ $6 6 6h6 .66k 2`1,k6 66  66  .6* T* `|T *#h`6  *#r+**#h h/W*% 0W*%1Y6 *2>\* 6** ** *:34** *W*>*5*'6W*%7*8* 9W9MPbvyVjmrHsnoma* *:Y;*Y?*@YA*BYC%*DY*%E'*** Ftuo+:+GLHY+IrHvno $jesd-0.0.7/com/jcraft/jesd/PluginException.java0000644000175000017500000000174607156066046020071 0ustar mjj29mjj29/* JEsd * Copyright (C) 1999 JCraft Inc. * * Written by: 1999 ymnk * * This program 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 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 Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jesd; public class PluginException extends Exception{ byte[] buff=null; public PluginException(byte[] buff){ this.buff=buff; } byte[] getBuff(){return buff;} } jesd-0.0.7/com/jcraft/jesd/StreamPlayerPlugin.java0000644000175000017500000000177507156066123020541 0ustar mjj29mjj29/* JEsd * Copyright (C) 1999 JCraft Inc. * * Written by: 1999 ymnk * * This program 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 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 Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jesd; import javax.sound.midi.*; import javax.sound.sampled.*; public interface StreamPlayerPlugin{ void play(SourceDataLine outputLine, java.io.InputStream in) throws PluginException; } jesd-0.0.7/com/jcraft/jesd/WAVEFile.class0000644000175000017500000000243707244161223016467 0ustar mjj29mjj29-N , - . /0 1 2 3456 7 8 39 : ; < = 3>?@wheaderLcom/jcraft/jesd/WAVEHeader;isLjava/io/InputStream;(Ljava/lang/String;)VCode ExceptionsA(III)V getHeader()[B readFrame([BI)I getFrameCount()I getFrameSize getChannelsgetRategetSampleFormatWidth getTrackBytesclose()V +  BC java/io/FileInputStream   D EFjava/lang/Exceptioncom/jcraft/jesd/WAVEHeader  %$ GH IJ KJ LJ MJ *+com/jcraft/jesd/WAVEFilejava/lang/Objectjava/io/IOExceptionparse0(Ljava/lang/String;)Lcom/jcraft/jesd/WAVEHeader;java/io/InputStreamskip(J)Jread([BII)IdatasizeIchannelsbitsrate! G3***+*Y+**XM.1 $*** Y  *!"2*+* h >:* l #$ ** l%$**lh&$*'$*($*)$**+*jesd-0.0.7/com/jcraft/jesd/WAVEHeader.class0000644000175000017500000000357707244161223017006 0ustar mjj29mjj29- *C D E F G H IJ K LM C NO NP NQR ST U NV3 NW NXYZ [ X\ ] N^ _ N` a b c d e f/ g1h HEADERSIZEI ConstantValue,RIFF[BWAVEfmt_dataformatratedatasizechannelsbitsheader(III)VCodeparse0(Ljava/lang/String;)Lcom/jcraft/jesd/WAVEHeader; getHeader()[B()V :B 7, 8, 90 4, 5, 6,java/io/FileInputStream :i jkcom/jcraft/jesd/IOLSBl mn op qrjava/lang/String :sfmt tu vp wx yBjava/lang/Exceptioncom/jcraft/jesd/WAVEHeader :;java/io/ByteArrayOutputStream :x z{ /0 |s }x 10 20 ~x 30 @ @java/lang/Object(Ljava/lang/String;)Vread([BII)Icom/jcraft/jesd/IOsetInputStream(Ljava/io/InputStream;)VreadInt()IreadByte([BII)V([B)Vequals(Ljava/lang/Object;)Z readShortreadPad(I)VclosesetOutputStream(Ljava/io/OutputStream;)V writeBytewriteInt writeShort toByteArraygetBytes * +,-. /0 10 20 304,5,6,7,8,90:;<0$*******=><bF<=>6666Y* ::   W: Y :    6  6       Y :  6  G 6  6 = 6 6 7 6 ' > d6   d6  k : Y:   Y* :  d   W LCC?@<***~ **~ *Y,L Y M,+, ,*$`!," ,# ,!,$,*$,*!,**lh!,$,*$,% ,*!*+&*L/AB<-!'()("(#(%jesd-0.0.7/com/jcraft/jesd/SamplePlayer.class0000644000175000017500000000262107244161223017516 0ustar mjj29mjj29-W * + , - . /, 01 /23 4 5 67 68 95 :; 9< 9= 0>?@ABsampleLcom/jcraft/jesd/Sample;clipLjavax/sound/sampled/Clip;loopZthreadLjava/lang/Thread;(Lcom/jcraft/jesd/Sample;)VCodeplay()Vrun stop_playingkillupdate"(Ljavax/sound/sampled/LineEvent;)V $    CD EF GHjava/lang/Thread I J$K LM NOP QRjava/lang/Exception ST U$ VFcom/jcraft/jesd/SamplePlayercom/jcraft/jesd/Playerjava/lang/Runnable javax/sound/sampled/LineListenercom/jcraft/jesd/Samplejavax/sound/sampled/LineaddLineListener%(Ljavax/sound/sampled/LineListener;)VplayerLcom/jcraft/jesd/SamplePlayer;(Ljava/lang/Runnable;)Vstartjavax/sound/sampled/ClipgetMicrosecondLength()JsetFramePosition(I)Vjavax/sound/sampled/DataLinesleep(J)VisActive()ZstopremoveLineListener  !"A5******+*+**+*#$"%** Y* * $"%** Y* * %$"g*^* @* *N** ****L'+.be&$"*'$"*()" jesd-0.0.7/com/jcraft/jesd/SamplePlugin.java0000644000175000017500000000170307156067754017354 0ustar mjj29mjj29/* JEsd * Copyright (C) 1999 JCraft Inc. * * Written by: 1999 ymnk * * This program 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 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 Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jesd; public interface SamplePlugin{ void play(java.io.OutputStream outputLine, java.io.InputStream in) throws PluginException; } jesd-0.0.7/com/jcraft/jesd/PluginException.class0000644000175000017500000000036507244161223020240 0ustar mjj29mjj29-   buff[B([B)VCodegetBuff()[B  com/jcraft/jesd/PluginExceptionjava/lang/Exception()V! ***+  *jesd-0.0.7/com/jcraft/jesd/SamplePlugin.class0000644000175000017500000000031407244161223017515 0ustar mjj29mjj29- play.(Ljava/io/OutputStream;Ljava/io/InputStream;)V Exceptions com/jcraft/jesd/SamplePluginjava/lang/Objectcom/jcraft/jesd/PluginExceptionjesd-0.0.7/com/jcraft/jesd/DaemonWithVorbis.java0000644000175000017500000000462607156106605020174 0ustar mjj29mjj29/* JEsd * Copyright (C) 1999 JCraft Inc. * * Written by: 1999 ymnk * * This program 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 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 Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jesd; import java.net.*; import java.io.*; public class DaemonWithVorbis extends Thread { static{ JEsd.installStreamPlayerPlugin("com.jcraft.jesd.vorbis.StreamPlayer"); JEsd.installSamplePlugin("com.jcraft.jesd.vorbis.Sample"); } static private int port=JEsd.ESD_DEFAULT_PORT; static private String key=null; static Object currentSound=null; private ServerSocket server=null; public DaemonWithVorbis(){ Auth.init(key); try{ server = new ServerSocket(port); } catch (IOException e) { System.out.println(e); } } public void run(){ if(server==null) return; // ?? while(true){ try { Socket socket = server.accept(); Client client = new Client(socket); client.start(); } catch (IOException e) { //System.out.println(e); } } } public void setPort(int p){port=p;} public void setKey(String k){key=k;} static void protoServerInfo(IO io) throws java.io.IOException{ int version=io.readInt(); io.writeInt(100); // version // ?? io.writeInt(44100); // rate io.writeInt(0x1021); // format } static void protoAllInfo(IO io) throws java.io.IOException{ int version=io.readInt(); io.writeInt(100); // version // ?? io.writeInt(44100); // rate io.writeInt(0x1021); // format // player Player.dumpInfo(io); io.writeInt(0); // source id io.writePad(JEsd.ESD_NAME_MAX+16); // sample Sample.dumpInfo(io); io.writeInt(0); // sample id io.writePad(JEsd.ESD_NAME_MAX+20); } public static void main(String args[]) { (new DaemonWithVorbis()).start(); } } jesd-0.0.7/com/jcraft/jesd/StreamPlayer.class0000644000175000017500000000722107244161224017532 0ustar mjj29mjj29- ^_`a bc d ?e >f >g >h >i >j >k >l >mn oq >tu >v w xy xz{ |} ~  e      > p > ? ? p ^ 3 p p | |  :  formatIratenameLjava/lang/String;left_vol_scaleright_vol_scale outputLine$Ljavax/sound/sampled/SourceDataLine;buffer[BthreadLjava/lang/Thread;frameSizeInBytesbufferLengthInBytes(class$javax$sound$sampled$SourceDataLineLjava/lang/Class; Synthetic(IILjava/lang/String;)VCodeplay(Lcom/jcraft/jesd/IO;)V terminate()Vupdate"(Ljavax/sound/sampled/LineEvent;)Vclass$%(Ljava/lang/String;)Ljava/lang/Class; ] java/lang/ClassNotFoundExceptionjava/lang/NoClassDefFoundError S SY FB GB HI JK LM AB CB DEjavax/sound/sampled/AudioFormat S!javax/sound/sampled/DataLine$InfoInfo InnerClasses PQ"javax.sound.sampled.SourceDataLine \] S "javax/sound/sampled/SourceDataLine ,javax/sound/sampled/LineUnavailableException java/lang/StringBuffer#Unable to open the sourceDataLine:  "java/lang/IllegalArgumentExceptionIllegal Argument: NB OBjava/lang/Exception  Y Q "com/jcraft/jesd/StreamPlayerPlugin V Y Y Y com/jcraft/jesd/PluginException  com/jcraft/jesd/StreamPlayercom/jcraft/jesd/Player javax/sound/sampled/LineListenerjava/lang/ClassforNamejava/lang/Throwable getMessage()Ljava/lang/String;(Ljava/lang/String;)V(FIIZZ)Vjavax/sound/sampled/DataLine6(Ljava/lang/Class;Ljavax/sound/sampled/AudioFormat;I)Vjavax/sound/sampled/AudioSystemisLineSupported"(Ljavax/sound/sampled/Line$Info;)ZgetLine;(Ljavax/sound/sampled/Line$Info;)Ljavax/sound/sampled/Line;javax/sound/sampled/LineaddLineListener%(Ljavax/sound/sampled/LineListener;)Vopen$(Ljavax/sound/sampled/AudioFormat;)Vjava/lang/SystemoutLjava/io/PrintStream;append,(Ljava/lang/String;)Ljava/lang/StringBuffer;,(Ljava/lang/Object;)Ljava/lang/StringBuffer;toStringjava/io/PrintStreamprintlnexit(I)V getFrameSize()I getBufferSize(Ljava/lang/Object;)Vadd(Lcom/jcraft/jesd/Player;)Vdelcom/jcraft/jesd/IOinLjava/io/InputStream;startcom/jcraft/jesd/JEsdstreamPlayerPlugin newInstance()Ljava/lang/Object;<(Ljavax/sound/sampled/SourceDataLine;Ljava/io/InputStream;)VdrainstopcloseremoveLineListenergetBuff()[Bwrite([BII)Ijava/io/InputStreamread([B)Ijavax/sound/sampled/Line$Info >?@ ABCBDEFBGBHIJKLMNBOBPQRSTUK'**d*d* * * * * *-Y~~ :YY:* * ** A:Y !"#$:Y& !"#*'(* )*(ll6**(h**** :,*-%.+VWU* * *.+/M* 01u123:* ,4* (* 5* 6* 7* *8+ +9::;:* <W* #,* =>* * <W* (* 5* 6* 7* *8+ +9:M*.gkn++qq:+ +XYU5)* * L* +6+7+*8*.Z[U \]U&*LY+Rspr |r jesd-0.0.7/com/jcraft/jesd/StreamPlayerPlugin.class0000644000175000017500000000034007244161224020704 0ustar mjj29mjj29- play<(Ljavax/sound/sampled/SourceDataLine;Ljava/io/InputStream;)V Exceptions "com/jcraft/jesd/StreamPlayerPluginjava/lang/Objectcom/jcraft/jesd/PluginExceptionjesd-0.0.7/example/0000755000175000017500000000000007030667105012552 5ustar mjj29mjj29jesd-0.0.7/example/Play.java0000644000175000017500000000523107031022750014313 0ustar mjj29mjj29/* JEsd * Copyright (C) 1999 JCraft Inc. * * Written by: 1999 ymnk * * This program 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 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 Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ import com.jcraft.jesd.*; public class Play{ Play(String[] arg) throws java.io.IOException{ String file=null; String host="localhost"; int i=0; for(;i0){ bytes_written+=frames_read*bytes_per_frame; if(jesd.write(buf, frames_read * bytes_per_frame)<=0) return; } System.out.println("byte_written="+bytes_written); jesd.close(); wave.close(); } public static void main(String[] arg){ try{new Play(arg);} catch(Exception e){} } } jesd-0.0.7/example/Sample.java0000644000175000017500000000712407031023063014630 0ustar mjj29mjj29/* JEsd * Copyright (C) 1999 JCraft Inc. * * Written by: 1999 ymnk * * This program 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 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 Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ import com.jcraft.jesd.*; import java.io.*; public class Sample{ Sample(String[] arg) throws java.io.IOException{ int rate=JEsd.ESD_DEFAULT_RATE; int bits=JEsd.ESD_BITS16, channels=JEsd.ESD_STEREO; int mode=JEsd.ESD_STREAM, func=JEsd.ESD_PLAY; int sample_id=0, confirm_id=0, reget_sample_id=0; int cache_mode=0; String file=null; String host="localhost"; int i=0; for(;i0){ if(jesd.write(buf, 0, length)<0) return; else total+=length; } confirm_id=jesd.confirm_sample_cache(); if(confirm_id!=sample_id){ System.out.println("error while caching sample <"+sample_id+ ">: confirm returned "+confirm_id); System.exit(-1); } fis.close(); System.out.println("sample <"+sample_id+"> upladed, "+total+" bytes"); } else if (cache_mode==0) { try{jesd=new JEsd(host);} catch(Exception e){ System.err.println(e); System.exit(-1); } sample_id=jesd.file_cache("sample", file); if(sample_id<0){ System.out.println("error while caching sample <"+sample_id+ ">: confirm value != sample_id"); System.exit(-1); } System.out.println("sample <"+sample_id+"> upladed: "+file); } else if (cache_mode==2){ } while(true){ System.out.println("press 'q' to quit, to trigger"); int key=System.in.read(); if('q'==(byte)key) break; jesd.sample_play(sample_id); } jesd.sample_free(sample_id); System.out.println("closing down\n"); jesd.close(); } public static void main(String[] arg){ try{ new Sample(arg); } catch(Exception e){} } } jesd-0.0.7/misc/0000755000175000017500000000000007244230407012050 5ustar mjj29mjj29jesd-0.0.7/misc/EsounD-protocol.txt0000644000175000017500000001673107244227557015671 0ustar mjj29mjj29EsounD Protocol (Draft) Author: ymnk Data: 2000-10-02 =============== Introduction ------------ This document describes the protocol in EsounD system. Unfortunately, any formal description about EsounD had not existed. So the author has tried to read the source code of EsounD and written this document. The author is also the author of JEsd, which is a re-implementation of EsounD in pure Java and this document is based on his knowledge, which was gotten in hacking JEsd. Connection Setup ---------------- The esd will wait for the TCP connection requests from EsounD compatible applications. In the default, esd will listen to the TCP port 16001. The client must send an initial byte of data to be authorized them-self and to identify the byte order to be employed. For authorization, client must send 'esd-key', which is a 16 byte data. For endian-ness, client must send a 4 byte data. If esd does not detect any error, '1' will be sent back and '0' will be sent back in error. Requests -------- lock: esd-key:ESDKEY w result:BOOLEAN At first, esd will check if the client has the right to lock the device by esd-key. If that client has the right to do so, esd will lock the device and send back true. If not, false will be sent back unlock: esd-key:ESDKEY w result:BOOLEAN At first, esd will check if the client has the right to unlock the device by esd-key. If that client has the right to do so, esd will unlock the device and send back true. If not, false will be sent back ... Syntactic Conventions -------------------- All numbers are in decimal, unless prefixed with '0x', in which case they are in hexadecimal(base 16). The general syntax used to describe data packets is: Name: encoded-form ... encoded-form For components described in the protocol descriptions as: name: TYPE w name: TYPE the encode-form are: N TYPE name and w N TYPE name N is the number of bytes in the data stream, and TYPE is the interpretation of those bytes. For example, result: BOOLEAN becomes: 4 BOOLEAN result For components with a static numeric value the encode-form is: N value name The value is always interpreted as a N-byte unsigned integer. Data Types ---------- CARD8: A single byte unsigned integer. CARD32: 32-bit unsigned integer ARRAY8: A collection of CARD8. ARRAY8(n): This is a ARRAY8, which includes 'n' elements. ENDIAN: This is a ARRAY8(4), which includes 'ENDN' or 'NDNE'. If the first element is 'E', data from clients is in big-endian. BOOLEAN: This is a CARD32 and includes '0' or '1'. '1' means true. ESDKEY: This is a ARRAY8(16), which includes 'esd-key'. ESDNAME: This is a ARRAY8(128), which includes 'esd-name'. ESDSTREAM: This is a infinite ARRAY8. FORMAT: This is a CARD32. Each bits in this data has following semantics, (format&0x000f)==0x0000 8bit data (format&0x000f)==0x0001 16bit data (format&0x00f0)==0x0010 mono (format&0x00f0)==0x0020 stereo (format&0x0f00)==0x0000 stream (format&0x0f00)==0x0100 sample (format&0x0f00)==0x0200 ADPCM (format&0xf000)==0x1000 play (format&0xf000)==0x0000 monitor for streams, stop for samples (format&0xf000)==0x2000 record for streams, loop for samples MODE: This is a CARD32, which is '0', '1', '2' or '3'. 0 ERROR 1 STANDBY 2 AUTOSTANDBY 3 RUNNING Packet Format ------------- init: 4 0 opcode 16 ESDKEY esd-key 4 ENDIAN 'ENDN' or 'NDNE' w 4 BOOLEAN 0 or 1 lock: 4 1 opcode 16 ESDKEY esd-key 4 ENDIAN unused w 4 BOOLEAN 0 or 1 unlock: 4 2 opcode 16 ESDKEY esd-key 4 ENDIAN unused w 4 BOOLEAN 0 or 1 stream-play: 4 3 opcode 4 FORMAT format 4 CARD32 rate 128 ESDNAME name ? ESDSTREAM stream of PCM sound //stream-mon: This protocol is not used for the remote esd. // 4 4 opcode // 4 FORMA format // 4 CARD3 rate // 128 ESDNAME name // w ? ESDSTREAM stream of PCM sound stream-mon: 4 5 opcode 4 FORMAT format 4 CARD32 rate 128 ESDNAME name w ? ESDSTREAM stream of PCM sound sample-cache: 4 6 opcode 4 FORMAT format 4 CARD32 rate 4 n size 128 ESDNAME name w 4 CARD32 sample-id n ARRAY8(n) stream of PCM sound w 4 CARD32 sample-id sample-free: 4 7 opcode 4 CARD32 sample-id w 4 CARD32 sample-id sample-play: 4 8 opcode 4 CARD32 sample-id w 4 CARD32 sample-id sample-loop: 4 9 opcode 4 CARD32 sample-id w 4 CARD32 sample-id sample-stop: 4 10 opcode 4 CARD32 sample-id w 4 CARD32 sample-id sample-kill: 4 11 opcode 4 CARD32 sample-id w 4 CARD32 sample-id standby: 4 12 opcode 16 ESDKEY esd-key 4 ENDIAN unused w 4 BOOLEAN 0 or 1 resume: 4 13 opcode 16 ESDKEY esd-key 4 ENDIAN unused w 4 BOOLEAN 0 or 1 sample-getid: 4 14 opcode 128 ESDNAME name w 4 CARD32 sample-id stream-filter: 4 15 opcode 4 FORMAT format 4 CARD32 rate 128 ESDNAME name w 4 BOOLEAN 0 or 1 server-info: 4 16 opcode w 4 CARD32 version w 4 CARD32 rate w 4 FORMAT format server-all-info: 4 17 opcode w 4 CARD32 version w 4 CARD32 rate w 4 FORMAT format w ? STREAMINFO w ? SAMPLEINFO STREAMINFO: except for last in series w 4 CARD32 id w 16 ESDNAME name w 4 CARD32 rate w 4 CARD32 left-vol-scale w 4 CARD32 right-vol-scale w 4 FORMAT format last in series w 4 CARD32 0 w 32 ARRAY8(32) unused SAMPLEINFO: except for last in series w 4 CARD32 id w 16 ESDNAME name w 4 CARD32 rate w 4 CARD32 left-vol-scale w 4 CARD32 right-vol-scale w 4 FORMAT format w 4 CARD32 sample-length last in series w 4 CARD32 0 w 36 ARRAY8(36) unused //subscribe: undefined // 4 18 opcode //unsubscribe: undefined // 4 19 opcode stream-pan: 4 20 opcode 4 CARD32 stream-id 4 CARD32 left-scale 4 CARD32 right-scale w 4 BOOLEAN 0 or 1 sample-pan: 4 21 opcode 4 CARD32 sample-id 4 CARD32 left-scale 4 CARD32 right-scale w 4 BOOLEAN 0 or 1 standby-mode: 4 22 opcode 4 0 version w 4 MODE mode w 4 BOOLEAN 0 or 1 latency: 4 23 opcode w 4 CARD32 latency