[
  {
    "path": ".project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>lakey</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t</buildSpec>\n\t<natures>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "LICENSE",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<https://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<https://www.gnu.org/licenses/why-not-lgpl.html>.\n"
  },
  {
    "path": "README.md",
    "content": "# lakey\nLakey, a CW training tool.\n\nLakey是一款摩尔斯电码发报练习软件，具有摩尔斯电码解析、音频频谱分析、摩尔斯电码听抄练习、可进行多主机网络通联练习或试验等特点。\n\n![photo](./doc/images/img21.png)\n\n常见问题临时解决方案:\n如果在Win7、Win8、Win10及以后版本的Windows上，包括32位和64位系统，遇到打开报错的问题，可以尝试检查是否打开了音频输入设备，一般插一个麦克风就好了。\n\n制作思想:\n- 简单至上，开箱即用，无需设置，简单直观。\n- 最小依赖，仅依赖操作系统自带库。\n- 短小精悍，体量仅200多KB。\n- 共同进步，完全开源。\n\n主要特性:\n\n- 利用键盘或鼠标进行摩尔斯电码发报练习，支持键盘直接录入，支持手键和自动键方式；\n- 摩尔斯电码听抄练习，可以将听抄音频转换为WAV文件，用于通过手机或其他移动设备进行听抄练习；\n- 摩尔斯电码解析，可以用做发报练习参考；\n- 音频频谱分析，可以对电脑音频模拟输入（Line in、Aux in或Mic in等）进行音频分析并显示；\n- 发报键状态可以输出到计算机I/O接口，对外围设备进行简单控制；\n- 可进行多主机网络通联练习或试验。\n\n本软件的目标是设计成一个使用简便，能够尽量利用一般PC本身具有的硬件功能和性能（主要指CPU的运算和声卡的音频捕捉/播放能力）， 实现不用另接特殊外围接口电路，不用改/加装电键等，即可让PC具有摩尔斯电码（Morse Code）的收发能力软件。未来可逐渐通过对PC硬件性能的挖掘， 实现对音频信号进行分析、过滤、处理。\n\n从Lakey 2.0版本开始，Lakey版本中将去掉RELEASE/BETA标记，取而代之的将是为每一个新的版本赋予一个有趣的名字代号。 如2.0版本被赋予Zongzi（粽子）这个代号。但应该说明，Lakey项目本身将继续立足于实验目的，因此作者并不保证所有功能都是完美可用的， 即所有版本可能都带有BETA测试版本的意味，这点请大家使用时务必注意。 同时希望大家继续多提意见，帮助作者不断完善Lakey。这点在对以往版本的改进过程中已经被证实是最为重要的手段。在此感谢所有提出过意见或建议的朋友们！\n"
  },
  {
    "path": "bin/Lakey.v2.1.build.0019.Pencil/lakey.ini",
    "content": "[CW]\r\nbeepfreq=1000.000000\r\nbeepvol=0.250000\r\nshorthit=80\r\nlonghit=240\r\nhitdelay=80\r\nletterdelay=240\r\nworddelay=240\r\n[GLOBAL]\r\nwindowrect=93,18,1013,454\r\n[JOURNAL]\r\nsendperiod=27\r\nsendidlelimit=750\r\nsendrect=5,235,490,267\r\nsendlabeloffset=0,-15\r\nsendlabel=Send\r\nsendqueuerect=5,270,490,281\r\nspecrect=498,10,908,160\r\nspeclabeloffset=0,-15\r\nspeclabel=Spectrogram\r\nrecvperiod=27\r\nrecvidlelimit=750\r\nrecvrect=5,180,490,212\r\nrecvlabeloffset=0,-15\r\nrecvlabel=Recieve\r\nrecvmrect=8,10,493,160\r\nrecvanalyzesamples=512\r\nrecvthreshold=0.300000\r\nrecvfreqstart=850\r\nrecvfreqend=1250\r\n[MAINPANEL]\r\ncw=500,290,297,92,000D,CW\r\nsendpause=603,265,91,16,0074,Pause,Continue\r\nsendfile=500,265,91,16,0075,File...\r\nautokeyswitch=706,265,91,16,0009,Manual,Auto(L/R),Auto(R/L)\r\nnoiseswitch=809,265,91,16,0076,Disturb\r\nsendvol=500,168,90,90,-80.000000,0.000000,0.000000,Volumn(dB)\r\nnoisevol=809,168,90,90,-80.000000,0.000000,0.000000,Disturb(dB)\r\nsendspeed=603,168,90,90,5.000000,30.000000,20.000000,Speed(wpm)\r\nspecbrightness=706,168,90,90,-60.000000,60.000000,1.875000,Spectrogram(dB)\r\n[KOCH]\r\ncharlist=\r\nkoch_wordlen=5\r\n[MORSE]\r\nA=00000002,00000003,0041\r\nB=00000007,0000000F,0042\r\nC=00000005,0000000F,0043\r\nD=00000003,00000007,0044\r\nE=00000001,00000001,0045\r\nF=0000000D,0000000F,0046\r\nG=00000001,00000007,0047\r\nH=0000000F,0000000F,0048\r\nI=00000003,00000003,0049\r\nJ=00000008,0000000F,004A\r\nK=00000002,00000007,004B\r\nL=0000000B,0000000F,004C\r\nM=00000000,00000003,004D\r\nN=00000001,00000003,004E\r\nO=00000000,00000007,004F\r\nP=00000009,0000000F,0050\r\nQ=00000002,0000000F,0051\r\nR=00000005,00000007,0052\r\nS=00000007,00000007,0053\r\nT=00000000,00000001,0054\r\nU=00000006,00000007,0055\r\nV=0000000E,0000000F,0056\r\nW=00000004,00000007,0057\r\nX=00000006,0000000F,0058\r\nY=00000004,0000000F,0059\r\nZ=00000003,0000000F,005A\r\n1=00000010,0000001F,0031\r\n2=00000018,0000001F,0032\r\n3=0000001C,0000001F,0033\r\n4=0000001E,0000001F,0034\r\n5=0000001F,0000001F,0035\r\n6=0000000F,0000001F,0036\r\n7=00000007,0000001F,0037\r\n8=00000003,0000001F,0038\r\n9=00000001,0000001F,0039\r\n0=00000000,0000001F,0030\r\n?=00000033,0000003F,0000\r\n/=0000000D,0000001F,006F\r\n(=00000012,0000003F,0000\r\n-=0000000E,0000003F,006D\r\n.=0000002A,0000003F,006E\r\n_=00000000,00000000,0020\r\n[HWCTRL]\r\nenableextport=00000000\r\nextportaddr=00000378\r\nopenbyte=000000FF\r\nclosebyte=00000000\r\n[NETWORK]\r\nnwenabled=1\r\nlocalport=3010\r\nhosts=0\r\n"
  },
  {
    "path": "bin/Lakey.v2.1.build.0019.Pencil/lakey_ZH.ini",
    "content": "[CW]\r\nbeepfreq=1000.000000\r\nbeepvol=0.250000\r\nshorthit=80\r\nlonghit=240\r\nhitdelay=80\r\nletterdelay=240\r\nworddelay=240\r\n[GLOBAL]\r\nwindowrect=224,104,1144,540\r\n[JOURNAL]\r\nsendperiod=27\r\nsendidlelimit=750\r\nsendrect=5,235,490,267\r\nsendlabeloffset=0,-15\r\nsendlabel=Send\r\nsendqueuerect=5,270,490,281\r\nspecrect=498,10,908,160\r\nspeclabeloffset=0,-15\r\nspeclabel=Spectrogram\r\nrecvperiod=27\r\nrecvidlelimit=750\r\nrecvrect=5,180,490,212\r\nrecvlabeloffset=0,-15\r\nrecvlabel=Recieve\r\nrecvmrect=8,10,493,160\r\nrecvanalyzesamples=512\r\nrecvthreshold=0.300000\r\nrecvfreqstart=850\r\nrecvfreqend=1250\r\n[MAINPANEL]\r\ncw=500,290,297,92,000D,CW\r\nsendpause=603,265,91,16,0074,ͣ,\r\nsendfile=500,265,91,16,0075,ļ...\r\nautokeyswitch=706,265,91,16,0009,ֶ,Զ(/),Զ(/)\r\nnoiseswitch=809,265,91,16,0076,\r\nsendvol=500,168,90,90,-80.000000,0.000000,-15.312500,(dB)\r\nnoisevol=809,168,90,90,-80.000000,0.000000,0.000000,(dB)\r\nsendspeed=603,168,90,90,5.000000,30.000000,20.000000,ٶ(wpm)\r\nspecbrightness=706,168,90,90,-60.000000,60.000000,55.781250,Ƶ(dB)\r\n[KOCH]\r\ncharlist=KMRSUAPTLOWI.NJEF0Y,VG5/Q9ZH38B?427C1D6X\u0005\u0005\u0005\u0005\u0005\u0005\u0005\u0005\rkoch_wordlen=5\r\n[MORSE]\r\nA=00000002,00000003,0041\r\nB=00000007,0000000F,0042\r\nC=00000005,0000000F,0043\r\nD=00000003,00000007,0044\r\nE=00000001,00000001,0045\r\nF=0000000D,0000000F,0046\r\nG=00000001,00000007,0047\r\nH=0000000F,0000000F,0048\r\nI=00000003,00000003,0049\r\nJ=00000008,0000000F,004A\r\nK=00000002,00000007,004B\r\nL=0000000B,0000000F,004C\r\nM=00000000,00000003,004D\r\nN=00000001,00000003,004E\r\nO=00000000,00000007,004F\r\nP=00000009,0000000F,0050\r\nQ=00000002,0000000F,0051\r\nR=00000005,00000007,0052\r\nS=00000007,00000007,0053\r\nT=00000000,00000001,0054\r\nU=00000006,00000007,0055\r\nV=0000000E,0000000F,0056\r\nW=00000004,00000007,0057\r\nX=00000006,0000000F,0058\r\nY=00000004,0000000F,0059\r\nZ=00000003,0000000F,005A\r\n1=00000010,0000001F,0031\r\n2=00000018,0000001F,0032\r\n3=0000001C,0000001F,0033\r\n4=0000001E,0000001F,0034\r\n5=0000001F,0000001F,0035\r\n6=0000000F,0000001F,0036\r\n7=00000007,0000001F,0037\r\n8=00000003,0000001F,0038\r\n9=00000001,0000001F,0039\r\n0=00000000,0000001F,0030\r\n?=00000033,0000003F,0000\r\n/=0000000D,0000001F,006F\r\n(=00000012,0000003F,0000\r\n)=00000012,0000003F,0000\r\n-=0000000E,0000003F,006D\r\n.=0000002A,0000003F,006E\r\n_=00000000,00000000,0020\r\n[HWCTRL]\r\nenableextport=00000000\r\nextportaddr=00000378\r\nopenbyte=000000FF\r\nclosebyte=00000000\r\n[NETWORK]\r\nnwenabled=1\r\nlocalport=3010\r\nhosts=0\r\n"
  },
  {
    "path": "doc/index.html",
    "content": "<html>\r\n<head>\r\n<meta http-equiv=content-type content=\"text/html; charset=utf-8\">\r\n<title>Lakey 2.1 Pencil (Build 0019) - CW/摩尔斯码/发报/收报/练习/音频分析/联网(CW, Morse code, Sending, Receiving, Training, Analyzing, Networking)</title>\r\n<style> \r\n\tbody { font-family: \"Helvetica Neue\", Helvetica, Arial, \"PingFang SC\", \"Hiragino Sans GB\", \"Heiti SC\", \"Microsoft YaHei\", \"WenQuanYi Micro Hei\", sans-serif; }\r\n\tp { text-indent: 20pt; font-size: 10pt; }\r\n\tli { font-size: 10pt; }\r\n\t.comment { border: #000000 1px solid; font-size: 9pt; margin: 18pt; }\r\n\th2 { color: #000090; }\r\n\th3 { color: #505080; }\r\n</style>\r\n</head>\r\n<body>\r\n<h1>Lakey 2.1 Pencil (Build 0019) - 使用手册</h1>\r\n<h5>CW/摩尔斯码/发报/收报/练习/音频分析/联网</h5>\r\n<hr>\r\n<h5 style=\"color: red\">永久开源、免费!</h5>\r\n<h5>最新下载(2012/6/30): </h5>\r\n<p style=\"color: blue\">[<a href=\"http://www.layala.org/lakey/download/Lakey.v2.1.build.0019.Pencil.bin.zip\">运行程序</a>]\r\n\t[<a href=\"http://www.layala.org/lakey/download/Lakey.v2.1.build.0019.Pencil.man.zip\">使用手册</a>]\r\n\t[<a href=\"http://www.layala.org/lakey/download/Lakey.v2.1.build.0019.Pencil.src.zip\">源代码</a>]</p>\r\n<br>\r\n<br>\r\n<br>\r\n<img src=\"images/logo.jpg\" alt=\"Lakey's logo\">\r\n<br>\r\n<br>\r\n<br>\r\n<br>\r\n<h5>版本:\t2.1.0019(Pencil)</h5>\r\n<h5>作者:\tBG1VLZ</h5>\r\n<h5>E-Mail/MSN: <a href=\"mailto:idirect3d@hotmail.com\">idirect3d@hotmail.com(非常希望能得到您的使用反馈, 谢谢!)</a></h5>\r\n\r\n<hr>\r\n<h2>目录</h2>\r\n<ul>\r\n\t<li><a href=\"#topic1\">写在最前</a></li>\r\n\t<li><a href=\"#topic2\">功能简介</a></li>\r\n\t<li><a href=\"#topic3\">收报</a></li>\r\n  <ul>\r\n    <li><a href=\"#topic31\">有趣的频谱</a></li>\r\n  </ul>\r\n    <li><a href=\"#topic4\">发报</a></li>\r\n\t<ul>\r\n\t\t<li><a href=\"#topic41a\">手动键发报</a></li>\r\n\t\t<li><a href=\"#topic41b\">自动键发报</a></li>\r\n\t\t<li><a href=\"#topic42\">字符发报</a></li>\r\n\t\t<li><a href=\"#topic43\">文件发报</a></li>\r\n\t\t<li><a href=\"#topic44\">与发信机的连接</a></li>\r\n\t\t<li><a href=\"#topic45\">发送暂停</a></li>\r\n\t</ul>\r\n\t<li><a href=\"#topic4a\">网络通联</a></li>\r\n\t<li><a href=\"#topic5\">参数调整</a></li>\r\n\t<ul>\r\n\t\t<li><a href=\"#topic51\">CW规则</a></li>\r\n\t\t<li><a href=\"#topic52\">发送</a></li>\r\n\t\t<li><a href=\"#topic53\">接收</a></li>\r\n\t\t<li><a href=\"#topic54\">练习</a></li>\r\n\t\t<li><a href=\"#topic55\">网络</a></li>\r\n\t\t<li><a href=\"#topic56\">I/O</a></li>\r\n\t\t<li><a href=\"#topic58\">参数调整失败怎么办?</a></li>\r\n\t</ul>\r\n\t<li><a href=\"#topic8\">练习</a></li>\r\n\t<ul>\r\n\t\t<li><a href=\"#topic81\">开始进行Koch模式练习</a></li>\r\n\t\t<li><a href=\"#topic83\">生成抄报练习音频文件</a></li>\r\n\t\t<li><a href=\"#topic85\">发报练习</a></li>\r\n\t</ul>\r\n\t<li><a href=\"#topic8a\">CW练习技巧</a></li>\r\n\t<ul>\r\n\t\t<li><a href=\"#topic8a1\">古典练习法</a></li>\r\n\t\t<li><a href=\"#topic8a2\">Koch练习法</a></li>\r\n\t\t<li><a href=\"#topic8a3\">Farnsworth练习法</a></li>\r\n\t</ul>\r\n\t<li><a href=\"#topic6\">系统需求</a></li>\r\n\t<li><a href=\"#topic7\">版本更新历史</a></li>\r\n</ul>\r\n<hr>\r\n<h2><a name=\"topic1\">写在最前</a></h2>\r\n \r\n<p>Lakey这是一个多功能且完全免费的CW练习/收/发软件，供大家学习研究，有需要源码的朋友可以访问Lakey的主页<a href=\"www.lakey.cn\">www.lakey.cn</a>下载\r\n(目前原域名: www.layala.org将继续使用), \r\n由于该主机使用动态DNS访问一台非固定IP主机, 并不能保证100% 7x24小时运行, 如果不能下载, 请给我发邮件或加为MSN索取(idirect3d@hotmail.com)。\r\n不便之处望朋友们谅解。在未来，我会不断改进其功能和修正错误。</p>\r\n\r\n  <p>最新的开发进展</p>\r\n  <p>v2.1(Pencil)</p>\r\n  <p>（1）实现了由BA3CE建议的发送练习功能，并能够将练习时发送的文本记录下来；</p>\r\n  <p>（2）新增加的频谱显示将频率坐标轴方向反向，即频率较低的数据显示在靠下的位置；</p>\r\n<br>\r\n  <p>v2.0(Zongzi)</p>\r\n  <p>（1）响应众多HAM朋友的意见，同时也是对过去Lakey功能缺陷的弥补，修正了自动键功能（感谢BG8ST及其他提出了此问题但没有留下呼号的朋友）；</p>\r\n  <p>（2）修正了“／”符号的Morse编码错误（感谢BD1GXH）；</p>\r\n  <p>（3）引入FFT算法；</p>\r\n  <p>（4）增加了频率域与时间域相结合的频谱分析显示功能。应该说，此功能是本次Lakey的最大功能升级。\r\n  它可以将混杂在实际嘈杂电波中的CW信号明显的“标记”出来，从而帮助接受者通过眼睛来识别Morse编码。\r\n  该功能的灵感来源于Foobar2000这款音乐播放软件的频谱分析功能。</p>\r\n \r\n \r\n<p>本软件的目标是设计成一个使用简便，能够尽量利用一般PC本身具有的硬件功能和性能（主要指CPU的运算和声卡的音频捕捉/播放能力），\r\n实现不用另接特殊外围接口电路，不用改/加装电键等，即可让PC具有摩尔斯电码（Morse Code）的收发能力软件。未来可逐渐通过对PC硬件性能的挖掘，\r\n实现对音频信号进行分析、过滤、处理。</p>\r\n \r\n<p>从Lakey 2.0版本开始，Lakey版本中将去掉RELEASE/BETA标记，取而代之的将是为每一个新的版本赋予一个有趣的名字代号。\r\n如2.0版本被赋予Zongzi（粽子）这个代号。但应该说明，Lakey项目本身将继续立足于实验目的，因此作者并不保证所有功能都是完美可用的，\r\n即所有版本可能都带有BETA测试版本的意味，这点请大家使用时务必注意。\r\n同时希望大家继续多提意见，帮助作者不断完善Lakey。这点在对以往版本的改进过程中已经被证实是最为重要的手段。在此感谢所有提出过意见或建议的朋友们！</p>\r\n \r\n<hr>\r\n<h2><a name=\"topic2\">功能简介</a></h2>\r\n \r\n<p>支持虚拟自动键和手键发送方式。</p>\r\n\r\n<p>支持多台计算机通过网络，实时进行CW通联和练习。</p>\r\n\r\n<p>支持对音频信号的频率域、时间域的单独和组合分析显示。</p>\r\n \r\n<p>利用PC声卡的音频捕捉播放功能，实现摩尔斯电码的收/发。收报时可自动实现摩尔斯电码到字母/数字的翻译转换；\r\n发报时可以选择采用手工CW或者直接键入字母/数字两种方式。</p>\r\n \r\n<p>手工方式可以使用键盘按键或者鼠标按键作为电键。也就是说，一台电脑通过普通音频连接线连接到普通发射/接收设备即可实现CW通信或练习。</p>\r\n \r\n<p>通过并口、串口或其它以I/O地址寻址的计算机接口，实现了对外部发信机的简单发射控制。</p>\r\n \r\n<p>生成任意抄报练习音频文件，可以放到手机等便携设备方便随时练习。</p>\r\n\r\n<p>支持发送练习。</p>\r\n \r\n<p>软件界面从上到下大体分为4部分，如下图所示：</p>\r\n\r\n<h5>英文模式(缺省)</h5>\r\n<img src=\"images/img21.png\" alt=\"Lakey英文界面\">\r\n\r\n<h5>中文模式(使用Lakey_zh.ini)</h5>\r\n<img src=\"images/img22.png\" alt=\"Lakey中文界面\">\r\n\r\n<p>\r\n    后面章节将对这些部分分别介绍。以上两种界面模式，可通过将不同.ini文件复制为Lakey.ini文件来实现。</p>\r\n \r\n<hr>\r\n<h2><a name=\"topic3\">收报</a></h2>\r\n \r\n<p>首先要把收信机的音频输出接到PC的音频输入口，如：Line in, Aux in, CD audio in等等。由于软件使用单声道处理，而一般这些接口都为双声道，因此最好将两个声道并联后接收信机的单声道输出。</p>\r\n<p>将操作系统的录音来源选择为接入的接口，如果来源选择不对将不能实现收报的摩尔斯码翻译。Windows的录音来源可进入[控制面板->声音和音频设备]中进行选择，如下图：</p>\r\n<img src=\"images/img31.jpg\">\r\n<p><b>在上面的窗口中点击录音栏中的[音量…]按钮</b></p>\r\n \r\n<img src=\"images/img32.jpg\">\r\n<p><b>在这里选择接入接收机音频输出信号的接口</b></p>\r\n<p>完成上面的步骤，就可以收报了。收报信息中包括输入音频的波形、简单频谱分析、CW点记录和翻译后的的字符。\r\n\t使用鼠标左键和右键点击频谱分析控件可以分别改变波形幅度和频谱分析坐标系（线性/对数）。</p>\r\n<p>要注意的是，在录音控制界面中，应尽量调整输入接口的电平，使软件显示的波形振幅尽量大且没有削波失真。</p>\r\n\r\n  <h3><a name=\"topic31\">有趣的频谱</a></h3>\r\n  <p>从Lakey2.0版本(Zongzi)开始，新增加了结合频率、时间、分布能量显示的综合频谱图。\r\n  这个功能，可以帮助收报者，从嘈杂的无线电环境中发现和辨别有规律CW信号。</p>\r\n  <p>在Lakey界面右上方新增加的这个频谱图形中，横轴为时间域（不断滚动），纵轴为频率域（CW“音频”波长），\r\n  某一点的亮度为某一时刻某一频点的振幅（可以理解音量或者能量）。\r\n  这里需要注意的是，在靠下方显示的是收信机输出音频频率较低的信号。</p>\r\n  <p>同一个电台的CW信号通过收信机输出后的音频信号，一般为一个固定频率，\r\n  在频谱显示时一般会体现在一条直线上。因此使用者可以通过寻找同一水平线上有规律的间断线段来识别一个电台。\r\n  而通过不同水平线也可以用来区分不同电台的信号。</p>\r\n  <p>使用者可通过调节频谱增益旋钮(Spectrogram)来调节频率显示增益（亮度），以实现最佳的显示效果</p>\r\n  <p>这里需要提醒使用者的是，实际的显示和使用效果，\r\n  与收信机接收信号质量/输出电平、计算机的录音端口增益设置、Lakey的采样数量设置（设置页面）、\r\n  Lakey的频谱增益设置（主界面Spectrogram旋钮）等都有直接或关联的关系，\r\n  组合调整这些设置使信号与背景噪音能够获得一个比较好的显示对比度，让收报者能够比较容易的辨别CW信号，\r\n  这通常需要充分利用收信机、计算机声卡以及数字处理程序的动态范围。\r\n  而这也许需要一点点耐心。</p>\r\n  <p>在未来，Lakey会不断完善频谱分析功能，适时推出计算机自动识别CW信号功能，甚至有可能实现多电台的自动识别和自动应答。\r\n  如果您在这方面有好的想法，可以联系我，作者在此先表示感谢！</p>\r\n \r\n<hr>\r\n<h2><a name=\"topic4\">发报</a></h2>\r\n\r\n<h5>发报主要分以下四种方式：</h5>\r\n<h3><a name=\"topic41a\">手键发报(Manual)</a></h3>\r\n<p>首先需要点击发送模式按钮，调整到“Manual”模式(缺省)，然后使用鼠标键点击“CW”按钮模拟手键发报，也可以使用键盘中的[Enter]键模拟手键发报。Lakey在按下按键时会发出声音，抬起时关闭声音，同时会在发送窗口显示键击记录，并试图用摩尔斯电码翻译为字符、数字或标点。不能翻译的部分显示为‘#’。</p>\r\n\r\n \r\n<h3><a name=\"topic41b\">自动键发报(Auto)</a></h3>\r\n<p>首先需要点击发送模式按钮，调整到“Auto”模式，然后使用鼠标左/右键点击“CW”按钮模拟自动键发报。自动键有L/R和R/L两种模式(di/da)，可以按照使用者习惯进行调整。与手动键一样，Lakey会对发送的信号进行翻译。</p>\r\n \r\n<h3><a name=\"topic42\">字符发报</a></h3>\r\n<p>直接敲击键盘上的字母或数字键，系统将自动把键入的信息转换成摩尔斯电码，并输出到发送队列；同时，在发报信息的最下部会显示这个发送队列。</p>\r\n<div class=\"comment\">\r\n注：发送队列是一个字符/数字队列，存放待发送的内容。发送队列长度为8192个字符，在队列满以后输入的字符将被舍弃。\t\r\n</div>\r\n \r\n<h3><a name=\"topic43\">文件发报</a></h3>\r\n<p>点击[File…]按钮，打开一个要发送的文件。系统将把打开文件中符合摩尔斯电码的字符内容发送到4.2中介绍的发送队列。</p>\r\n \r\n<h5>其他关于发报的主题：</h5>\r\n \r\n<h3><a name=\"topic44\">与发信机的连接</a></h3>\r\n \r\n<h5>音频连接方式</h5>\r\n \r\n<p>这种方式适用于当使用非CW方式发射模式时，如使用FM方式搭载摩尔斯音频信号的方式。现在在U/V段已经有利用这种方式进行摩尔斯收发练习的HAM，如北京的144.650MHz。</p>\r\n \r\n<p>如果需要将音频摩尔斯电码发送到发信机，只需将PC的音频输出接到发信机的音频输入端口即可。</p>\r\n \r\n<div class=\"comment\">注意，对于多声道声卡来说，应该将前主声道（左或右）的信号接到发信机的音频输入端。</div>\r\n \r\n<h5>并口连接方式</h5>\r\n \r\n<p>这种方式适用于当使用标准CW方式发射模式时。当使用鼠标、键盘进行击发，或者键盘字符输入、文本文件输入时，通过并口的某一个针脚的电平来控制CW发信机起停，从而代替传统电键进行CW发射。其中，并口输出针脚电平规则可以通过设置界面随意调整。祥见：<a href=\"Topic54.htm\">端口控制</a></p>\r\n \r\n<div class=\"comment\">注意，计算机的并口输出电平，在没有应用程序进行控制时，其电平状态有可能是随机的；因此，如果希望使用电脑通过并口控制发信机，保险起见，应当首先启动本应用程序，再连接或打开发信机。</div>\r\n \r\n<p>并口具体针脚定义如下：</p>\r\n<table>\r\n\t<tr><td>针脚序号</td><td>说明</td></tr>\r\n\t<tr><td>1</td><td>STROBE 选通</td></tr>\r\n\t<tr><td>2-9</td><td>DATA0-DATA7 数据0-7</td></tr>\r\n\t<tr><td>10</td><td>ACKNLG 确认</td></tr>\r\n\t<tr><td>11</td><td>BUSY 忙</td></tr>\r\n\t<tr><td>12</td><td>PE 缺纸</td></tr>\r\n\t<tr><td>13</td><td>SLCT 选择</td></tr>\r\n\t<tr><td>14</td><td>AUTO FEED 自动换行</td></tr>\r\n\t<tr><td>15</td><td>ERROR 错误</td></tr>\r\n\t<tr><td>16</td><td>INIT 初始化</td></tr>\r\n\t<tr><td>17</td><td>SLCT IN 选择输入</td></tr> \r\n   \t<tr><td>18-25</td><td>GND 地线</td></tr>\r\n</table> \r\n \r\n<h3><a name=\"topic45\">发送暂停</a></h3>\r\n \r\n<p>点击[Pause]按钮可以暂停发送发送队列中的内容。再按[Continue]继续发送。这里需要说明的是，在暂停时仍可使用直接CW键击发报。</p>\r\n \r\n<hr>\r\n<h2><a name=\"topic4a\">网络通联</a></h2>\r\n \r\n<p>Lakey现在可以支持网络通联，如果您希望与另一个HAM通过网络进行通联，那么需要进行以下两步操作：1、启用网络通联功能（参见：<a href=\"#topic55\">网络</a>）；2、了解对方的IP地址，并且在<a href=\"#topic55\">网络</a>参数中，将对方IP地址添加到主机列表中。设置好以上两步，您所发送的摩尔斯电码将通过网络传送到对方主机，并通过扬声器和显示器传达给对方。</p>\r\n \r\n<hr>\r\n<h2><a name=\"topic5\">参数调整</a></h2>\r\n \r\n<h5>从菜单 - 工具->设置 可以进入配置界面：</h5>\r\n<img src=\"images/img51.jpg\" alt=\"Lakey配置界面 - CW规则参数\">\r\n<p><b>在这里可以对系统用到的大多数参数进行调整</b></p>\r\n<h5>下面是这些对这些参数的详细说明：</h5>\r\n \r\n<h3><a name=\"topic51\">CW规则</a></h3>\r\n \r\n<li><b>\"滴\"声长(ms)：</b>摩尔斯电码中的短鸣声。</li>\r\n<li><b>\"哒\"声长度(ms)：</b>摩尔斯电码中的长鸣声。</li>\r\n<li><b>键击间隔(ms)：</b>在一个字符电码中按键的间隔。</li>\r\n<li><b>字符间隔(ms)：</b>字符与字符之间的延迟时间。</li>\r\n<li><b>键速(wps)：</b>按标准单词长度（1 word = “PARIS”），计算的发报速度。\r\n \r\n<p>上面的规则即适用于发送，也适用于接收分析。应适当调整，以适应自身习惯和接收信号的特点。</p>\r\n \r\n<h3><a name=\"topic52\">发送</a></h3>\r\n<br>\r\n<img src=\"images/img52.jpg\" alt=\"Lakey配置界面 - 发送参数\">\r\n<br>\r\n</li>\r\n<li><b>音调(Hz)：</b>CW发送的嘀嗒声基准频率；缺省值，1KHz</li>\r\n<li><b>音量(0~1)：</b>CW发送的嘀嗒声音量。这里实际调整的是生成波形的振幅比例，1为最大，0为最小。具体输出音量也可以通过操作系统的“音量控制”来调节; 缺省值, 0.250000</li>\r\n<li><b>采样间隔(ms)： </b>对CW发送内容的采样间隔，适当提高采样间隔可以提高对发送内容分析精度。</li>\r\n<li><b>空闲停止(ms)：</b>当一定时间无输出时，停止记录，避免过多空白出现。</li>\r\n<li><b>CW键：</b>这里是一个CW键的Win32键盘代码(Win32 Virtual key code)，下面列出几个常用键代码：\r\n<div class=\"comment\">回车：13，空格：32，Shift：16，Tab：9，上：38，下：40，左：37，右：39</div>\r\n</li>\r\n<li><b>空格延迟(ms)：</b>空格延迟时间长度。\r\n \r\n<h3><a name=\"topic53\">接收</a></h3>\r\n<br>\r\n<img src=\"images/img53.jpg\" alt=\"Lakey配置界面 - 接收参数\">\r\n<br>\r\n</li>\r\n<li><b>采样数量：</b>每次分析接收音频的采样点数量，数值约大，精度约高；可以参考下面的规则：\r\n<div class=\"comment\">分析最小频率单位 = 44100 / 2 / 采样数量 = 22050 / 采样数量</div>\r\n<p>但要注意的是，过多的采样数量会过多的消耗CPU资源，有可能造成对其他功能的影响！经测试，使用Intel(R) Core(TM)2 Duo T6670@2.2GHz，采样数量设定为256时，CPU占用率小于20%，平均为15%左右。</p>\r\n</li>\r\n<li><b>采样间隔(ms)：</b>对CW接收内容的采样间隔；从b0017版开始，此数值已经不对接收内容分析精度有任何影响，而只影响分析的实时性。</li>\r\n<li><b>空闲停止(ms)：</b>当一定时间无接收内容时，停止记录，避免过多空白出现。</li>\r\n<li><b>阀值电平(0~1)：</b>只有大于这个输入电平的音频信号才被当作是摩尔斯电码信号进行分析。</li>\r\n<li><b>起始频率(Hz) 和 截止频率(Hz)：</b>只有大于起始频率和小于截止频率的信号分量才参与摩尔斯电码信号分析。这样可以起到过滤杂波的作用。接收的CW音频信号频率应该包含在起始频率至截止频率这个范围内，但要注意的是，这个范围不应过小，应该保持在200Hz以上。这个可以从介绍“采样数量”时提到的公式得到，如果过小的范围，将有可能不被包含在最小分析区间！\r\n \r\n<h3><a name=\"topic54\">练习</a></h3>\r\n<br>\r\n<img src=\"images/img54.jpg\" alt=\"Lakey配置界面 - 练习参数\">\r\n<br>\r\n</li>\r\n<li><b>字符集：</b>指定在练习模式或生成的练习音频文件中使用的字符。字符可以重复，出现次数多的字符在练习时出现的概率也相应增加。</li>\r\n \r\n<li><b>字长度：</b>指定在练习模式或生成的练习音频文件中多少字符为一组，组与组之间使用相当于空格延迟时间长度的空白分开。\r\n \r\n<h3><a name=\"topic55\">网络</a></h3>\r\n<br>\r\n<img src=\"images/img55.jpg\" alt=\"Lakey配置界面 - 网络参数\">\r\n<br>\r\n</li>\r\n<li><b>本地端口：</b>用于网络通讯的SOCKET端口，UDP类型。</li>\r\n \r\n<li><b>启用网络：</b>是否允许Lakey通过网络进行发送和接收操作。</li>\r\n \r\n<li><b>主机 - IP/端口/列表：</b>录入对方主机IP地址和端口，点击右边的“添加”按钮，可以将录入的主机加入静态主机列表，在列表中的主机将能接收到您发送的摩尔斯信号。\r\n \r\n<h3><a name=\"topic56\">I/O</a></h3>\r\n \r\n<br>\r\n<img src=\"images/img56.jpg\" alt=\"Lakey配置界面 - I/O参数\">\r\n<br>\r\n</li>\r\n<li><b>地址(HEX)：</b>外部设备连接到计算机上端口的内部地址。如：打印端口通常为16进制的0378(默认)。为安全起见，此参数不能在此处修改。如有特别需要，可以调整Lakey.ini中的extportaddr属性值。</li>\r\n \r\n<li><b>开启(HEX)：</b>相当于电键按下时端口的输出状态。</li>\r\n \r\n<li><b>关闭(HEX)：</b>相当于电键抬起时端口的输出状态。\r\n \r\n<p>上面的开启和关闭两个参数，对应端口的输出数据；如：当设置为01时，相应设置状态下的输出为16进制的01，对于0378并口来讲，就是2针(D0)为高电平，3-9针(D1-D7)为低电平。</p>\r\n \r\n<h3><a name=\"topic58\">参数调整失败怎么办?</a></h3>\r\n \r\n<p>由于软件还处于测试期间，并未对参数进行合法性检查，如果不适当的调整参数，有可能造成软件不能启动。如果发生这种问题，可以把运行目录中的Lakey.ini文件删除，软件即可按照缺省参数启动。</p>\r\n \r\n<hr>\r\n<h2><a name=\"topic8\">CW练习</a></h2>\r\n \r\n<h5>Lakey可以在不使用外围电路的情况下，由键盘或鼠标键击发出di dah声，来练习发报，祥见：</h5>\r\n</li>\r\n<li><a href=\"#topic4\">发报</a>\r\n \r\n<h3><a name=\"topic81\">开始进行Koch模式练习</h3>\r\n \r\n<h5>从菜单 - 工具->Koch训练法或者使用快捷键[Ctrl+K]都可以启动Koch模式练习功能。</h5>\r\n<p>启动时系统会提示如下图所示的对话框：</p>\r\n<img src=\"images/img81.jpg\" alt=\"Lakey Koch训练开始提示\">\r\n<p>点击[确定]按钮或按[回车]键，系统弹出抄录栏，同时开始自动发报，正式开始Koch模式练习。抄录栏如下图所示：</p>\r\n<img src=\"images/img82.jpg\" alt=\"Lakey Koch训练听抄录入界面\">\r\n<p>训练过程中，错码会用红色标出，并在窗口下部的统计栏内显示统计实时信息，供练习者参考。如下图所示。</p>\r\n<img src=\"images/img83.jpg\" alt=\"Lakey Koch训练成绩统计界面\">\r\n<p>抄录中途可以通过点击[完成]按钮来结束训练模式。再点击[关闭]按钮退出Koch训练模式。也可以点击[ESC]键直接退出训练模式。</p>\r\n \r\n<h3><a name=\"topic83\">生成抄报练习音频文件</a></h3>\r\n \r\n<h5>从菜单 - 工具->生成CW音频文件。</h5>\r\n<p>从这里可以生成任意字符的音频文件。</p>\r\n \r\n<h5>从菜单 - 工具->生成Koch音频文件。</h5>\r\n<p>从这里可以使用配置在<a href=\"#topic54\">参数调整</a>中练习里的字符集，生成随机序列的音频文件。</p>\r\n \r\n \r\n<h3><a name=\"topic85\">发报练习</a></h3>\r\n\r\n<h5>从菜单 - 工具->发报练习。<h5>\r\n<p>Lakey会提示你选择一个文本文件，这个文件应含有报底文本。选择好文件后，您就可以开始发报了。\r\n发报时Lakey会实时解析你所发送的Morse码，但并不会提示是否与报底相同。因此，你在练习时应确保发送的内容与报底同步，否则事后Lakey的正确率统计将会不正确。\r\n当然，如果不同步也没有关系，如果对Lakey统计的正确率有疑问，可以到报底文件所在文件夹下寻找一个以报底文件名为前缀，后缀为“.jrn”的记录文件。\r\n该文件会完整记录Lakey的解析结果，对于错误或者不认识的字符会以“＃”替代。\r\n</p>\r\n\r\n<h2><a name=\"topic8a\">CW练习技巧</h2>\r\n \r\n<p>时下对CW感兴趣的HAM越来越多，这里搜集了几篇关于学习CW方法/技巧的文章，供朋友们参考。</p>\r\n \r\n</li>\r\n \r\n<li><a href=\"#topic8a1\">古典练习法</a></li>\r\n<li><a href=\"#topic8a2\">Koch练习法</a></li>\r\n<li><a href=\"#topic8a3\">Farnsworth练习法</a>\r\n \r\n<p>个人认为上面这几种方法在练习时选择其中一种即可，多种方法混用时可能会产生混乱。</p>\r\n \r\n<p>文章全部从Internet上收集，其版权属于原作者所有，如被收集文章的作者认为文章出现在此处并不妥当，请联系我（联系方法在首页），我会立即从这里删除。</p>\r\n \r\n<h3><a name=\"topic8a1\">古典练习法</a></h3>\r\n<i>(摘自BG1TGP在ham.it168.com论坛上发表的<a href=\"http://bbs.it168.com/viewthread.php?tid=362582&pid=1954353&page=1&extra=page%3D1#pid1954353\">《致HAM初学CW的建议》一文 </a>)</i>\r\n \r\n<h5>致HAM初学CW的建议</h5>\r\n<p>给大家一点学习CW的建议，如果原先无基础还是先从记忆英文字母、数字、常用标点符号的电码符号开始，这是第一步也是基础，就象小学生学习一篇满是生字的课文一样，要想让别人听写你首先得能读下来，要想读下来首先得把生字认识了，那么所有字符对应的电码符号一共也就几十个这个应该不是什么问题吧.</p>\r\n<p>另外还可以利用CW练习软件进行辅助练习，敲击键盘电脑就会发出字符对应的电码符号读音，电脑发完了你就跟它学着读速度不易过快，当你已经不能满足按照A----Z/0----9的有规律的报底的时候可以将顺序打乱编辑一段报底，还是由电脑领读你来学着读，将间隔时间设定的大一点留出你跟读的时间，这期间还可以穿插完全读报底的练习，对卡壳的字母重点练习，其实记忆的过程就是在不断的重复中实现的。</p>\r\n<p>下一步我们就要跟电脑学习读报底的节奏了，将一些单词组成短句并用空格来隔出单词之间的间隙存在电脑里并抄写下来一份报底，还是由电脑来领读你来跟读，达到一定的熟练程度后可以试着和电脑同期读，重点是掌握正确的读音和节奏，期间可以随便找些英文的书或报纸等作为报底来读，你读的有多熟练就证明你记忆的有多熟练，和电脑同期练习时你读的和电脑发的有多同步就证明你将来发报时的节奏有多标准。这只是刚刚开始还没到练习收报的时候，这个阶段就是记忆－－－电脑领读你跟读－－－自己按报底读－－－和电脑同步读，总之就是一个字－－－－读。</p>\r\n<p>如果报文不长速度也不快不压码也可以，但是最好是养成压码收报的习惯，压码的好处是可以让你收报更轻松，比如当报文中出现E--I等电码符号特别短的字母连在一块的时候如果你不会压码收报就会觉得手忙脚乱，因为当你听到E的电码符号后需要大脑来辨别这个“嘀”是什么字母，然后手要把这个字母写下来或在键盘上撬出来，可是还没等你写完的时候第二I又来了，等你写第二个的时候第三个又来了，假如下一个是9你又会觉得时间太长还得等他一会，由于电码符号的长度不均匀就会出现上面的现象，这样的化你的书写势必会影响到你的听辨。收报的过程是耳朵听－－－大脑辨－－－手来写，节奏由各电码符号的时间长度决定，遇到符号少的时间就短要是几个连在一块就手忙脚乱，那么压码收报就可以把由于各字符电码符号时间长度不同带给你的处理时间不同的矛盾在一定程度上给化解了，当听辨出第一个电码后不下笔写先记在脑子里，集中精力听第二个，当听辨出来第二个电码后下笔写第一个，把第二个在记在脑子里集中精力听第三个依次类推，就是耳朵不停的听，脑袋不停的辨，手不停的写，压码的本领是通过训练获得的，刚开始可能不太习惯时间长了就好了，你会发现你的收报节奏不在受电码时间长度的影响完全在你的掌握之中，压一到两个码基本就够了就会轻松不少，试一试等你的好消息。</p>\r\n \r\n<h4><a name=\"topic8a2\">Koch练习法</a></h4>\r\n<i>(摘自BG1WZ在www.hellocq.net论坛上名为<a href=\"http://www.hellocq.net/forum/showthread.php?t=29205&page=1&pp=30\">《学习CW的捷径》的帖子及其回帖</a>)</i>\r\n \r\n<p>Koch Method被证明是一种很少失败的训练方法。简单说来一开始只用标准速度（至少15 wpm）听2个字符，达到90％抄收的水平之后增加第三个字符，3个字符一起练习，再达到90％抄收的水平之后增加第四个字符，如此与时俱进，基本上使用高速度养成条件反射。训练选择的字符不从最简单的E或T开始，推荐的学习顺序是：</p>\r\n<p><b>K M R S U A P T L O W I . N J E F 0 Y , V G 5 / Q 9 Z H 3 8 B ? 4 2 7 C 1 D 6 X &lt;BT&gt; &lt;SK&gt; &lt;AR&gt;</b></p>\r\n \r\n<h5>译一篇文章——如果你希望学习莫尔斯码</h5>\r\n<p><br><i>如果你希望学习莫尔斯码<br>\r\n忘记挫折：获得有价值的莫尔斯技巧并增加你的业余无线电乐趣<br><br>\r\n \r\n作者：Dave Finley, N1IRZ　译：BG1WZ（译者注：译文有删节）<br><br>\r\n关于莫尔斯码训练的完整信息、CW操作、历史和更多，请参见作者的书：《莫尔斯码：突破障碍》（原名：《Morse Code: Breaking the Barrier》），由MFJ Enterprises, Inc.出版。<br></i>\r\n</p>\r\n<p>业余执照做了一些调整，你不再需要通过13或20wpm的考试才能获得完全的操作许可，只要通过5-wpm的考试就得到一切。但是为什么你不做得更多些？具有熟练的莫尔斯码水平，也就是可以抄收12-13 wpm或更多，能够从业余无线电的空中得到无限的乐趣。许多有兴趣的短波活动如远程接收，比赛和QRP操作是依靠CW完成的。数千ham把CW当做他们自己有别于其他通讯手段的休闲方式，甚至在VHF和更高的频率你可以发现激动人心的月面反射和弱信号通联仍然有赖于熟练的莫尔斯技巧。\r\n一般认为达到13或20wpm速度几乎是不可逾越的障碍，这种理解是不对的。只要花费比通过5-wpm考试不多的时间投入，你就能得到真正高速的抄收能力，增强你对这一业余爱好的兴趣。你听到的许多有关学习莫尔斯码的说法是错误的——绝对错误。业余无线电界传统使用极慢的、最使人灰心丧气的、最痛苦和最无效的方法学习莫尔斯码。你能够获得真正的熟练技巧，你能够在相当短的时间内以最少的挫折和痛苦得到这些。它要求实地操作，你需要每天拿出15-30分钟进行训练直到达到目标。你可能在一个月或七个月内成功，个人的差异是巨大的。</p>\r\n<p>这里有什么新方法？训练方法是德国心理学家Ludwig Koch在大约60年前发明的，最少的挫折和充分的加强使你可以尽快的进步。</p>\r\n<p>让我们丢弃一些ham-radio传统上出现过的废物，开始走上成功之路。它们是：</p>\r\n<p>●慢速(5\r\nwpm)电码——用这个速度教任何人都应该看为非法的，绝对是一种浪费。而且保证会在将来出现困难以至学不下去。5 wpm和15或20wpm的电码完全是两回事，你当然不希望在错误上浪费时间。</p>\r\n<p>●对照表，记忆术，音乐的暗示和其他记忆帮助——这些事情让你在试图抄收电码的时候还要想别的，对于精确抄收是致命的。</p>\r\n<p>●训练磁带——很短时间内，你不知不觉的记忆了磁带的内容，并对自己的能力建立起虚假的信心。这种虚假的信心在你听到未曾记忆的电码时很快就会被粉碎。</p>\r\n<p>●抄收空中的QSOs——你不知道频率上发码的速度，而且许多电码发得很差，无助于训练的目的。正规的练习课程例如W1AW所发的当然不在此例。</p>\r\n<p>技巧：训练什么，怎样练？</p>\r\n<p>去电报操作员的工作房间或参观俱乐部野外电台的CW操作，看一看他们在30到35\r\nwpm速度的收和发。你将注意到他们做这些很轻松，并不费脑子，电码已经成为他们的第二语言。关键是熟练程度。抄收必须是无需思考的处理，听到就知道了，不用想它是什么。这是一种条件反射，实际上抄收速度超过10 wpm就只能靠反射，靠脑子想就太慢了。这就是为什么说过慢的速度是致命的陷阱，为什么传统的业余莫尔斯码训练痛苦又困难。许多ham先记忆了全部字符，然后开始提高速度。他们不断在脑子里查表，把听到的码与头脑里的表相比较，找出相符的。这样的处理到10 wpm左右就行不通了，所以经常有人停留在10 wpm的水平，数周或数月没有任何进步。\r\n他们最终越过“驼峰”，超过10 wpm是因为持续的练习使他们用反射代替了思考，他们是幸运的。10 wpm的障碍使许多人在挫折面前选择了放弃。于是莫尔斯码训练完全避免“查表”阶段而用建立条件反射实现熟练的抄收。最初是1930年代德国心理学家Ludwig Koch认识到这一点，设计出非常有效的莫尔斯码训练方法。</p>\r\n<p>用Koch方法练习莫尔斯码</p>\r\n<p>Koch方法简单、直接地建立起条件反射。然而它要求一台电脑加软件或一个教师的协助，这也是它在过去许多年受到冷落的原因。现在电脑很普及，也有望成为标准的莫尔斯码训练方法。它的工作过程是：</p>\r\n<p>准备好纸和铅笔，设置你的电脑（或微处理器构成的电码练习器）以20 wpm的速度发送莫尔斯字符（最少也要15 wpm）——但是仅仅2个字符。是的，这是第一课，你只有两种选择。在纸上抄收5分钟，停下机器，把你抄收的结果与机器发送的字符做比较，计算字符数目和抄收正确的百分比。</p>\r\n<p>如果你的正确率是90％或更高——恭喜你！你已经学完了最初的2个字符。并且非常重要的，你是用全速学会的，再也不需要重新学习它们。如果你的正确率不足90％，需要继续练习。</p>\r\n<p>一旦你抄收前2个字符达到90％的正确率，就在练习中增加第三个字符。增加新字符后你的正确率会下降，但是很快会上升到超过90％，这时再加上第四个字符，如此类推。</p>\r\n<p>这个方法不允许你在脑子里建立一个对照表，为了90％正确率的全速抄收，你必须建立起条件反射，我们花费时间练习就是这个目的，就像练习打网球或体操一样，练习到你掌握了它。逐字学习的Koch方法有点和训练打字的盲打相像，那是另一个必须建立条件反射的技巧。</p>\r\n<p>这是一个非常独特的训练方法——以你自己最好的速度前进，只为增加每个新字符花费时间，在达到目标的途中不浪费时间。</p>\r\n<p>多少时间是必须的？这取决于个人。以Koch来说，他挑选的一组学生掌握12\r\nwpm的电码平均仅用13.5小时。你也许不完全是这样，但它确实比心理学文献记录的任何方法更快。在熟练掌握一些字符之后你就能估算出总的学习时间。跟踪你的训练课程（一些软件可以为你做）并计花费在每个字符上的时间，乘上43（业余莫尔斯码考试所用）就是总的时间。</p>\r\n<p>虽然Koch方法是练习莫尔斯码最快的方法，速度并不是它最基本的好处，基本的好处和它有别于其他训练方法的是让你不断的得到肯定和加强。随着你的实践，刚掌握2个字符时已经达到15或20 wpm，随后每一个新字符的加入都更多的验证了你的进步。与慢慢的建立4或5 wpm速度，碰到10 wpm的平台长时间不能进步相比，Koch方法可能遇到的挫折是最小的。</p>\r\n<p>不断的测试是保证你使用Koch方法得到最大效益所必需的。必须抄收在纸上，这样才能给自己定级。一定要记住，如果准确率达到或超过90％就加一个字符。如果少于90％，要继续练习。最少每5分钟测试一次，决定什么时候增加字符，可以使进度最快。</p>\r\n<p>使用Koch方法学习，直到你掌握完整的字符集之前，自然抄收的是随机的字符组而不是单词。如果你的软件允许，让这些字符具有随机的长度，而不是固定的5个字符一组，这样更接近实际的单词。单词和随机的字符组之间在节奏和“感觉”上确实存在差异。当你能够熟练抄收单词，就可以抄收简单的QSO，这是业余无线电考试的格式。特别留意呼号、位置和数字的抄收，这些内容往往成为考试重点。\r\n</p>\r\n \r\n<h4><a name=\"topic8a3\">Farnsworth练习法</a></h4>\r\n<i>(摘自BG1WZ在www.hellocq.net论坛上名为<a href=\"http://www.hellocq.net/forum/showthread.php?t=29205&page=1&pp=30\">《学习CW的捷径》的帖子及其回帖</a>)</i>\r\n \r\n<h5>学习CW的捷径</h5>\r\n<p>近日浏览了几个莫尔斯码学习软件，几乎都提到了Farnsworth\r\nMethod，于是又去搜索法恩斯沃斯方法的含义，中文内容竟然搜索不到(繁体的有一条)。只好费劲读英文，读过几段总算基本弄清了，现在把有关情况作一介绍，也许对新手学习CW有所帮助。</p>\r\n<p>'Farnsworth'（法恩斯沃斯）方法的中心就是对于初学者不过分降低每个字符的发送速度（一般为每分钟15－18词wpm），只是加大字符之间的空隙（例如使用5wpm的空间）。一旦你确认能够分辩出每个字母、数字、符号，就开始减少字符间的空隙。</p>\r\n<p>这时每个字符的声音没有改变——你已经熟悉了，不用再次学习，因此很快可以把速度提上去。更慢的字符速度会诱使你去数点和划，造成更难于按它有特性的节奏声音去识别的困难。</p>\r\n<p>许多CW软件的作者（基本上都是ham）反对背记字符/莫尔斯码对照表。因为那样学习的结果会导致听到电码之后再到脑子里去“查表”，速度很难提高。他们也反对背记分离的di dah，提倡把一个字符的CW码作为一个声音来记忆。我理解这样记忆的结果不但反应速度快，点/划/空间的比率也不用考虑，一起记忆了。</p>\r\n \r\n<hr>\r\n<h2><a name=\"topic6\">系统需求</a></h2>\r\n<br>\r\n</li>\r\n<li>支持DirectSound的全双工声卡</li>\r\n<li>P3或同级别CPU</li>\r\n<li>IP网络适配器（可选）</li>\r\n<li>并行/串行接口（可选）\r\n\r\n<hr>\r\n<h2><a name=\"topic7\">版本更新历史</a></h2>\r\n<br>\r\n \r\n</li>\r\n \r\n<li style=\"color: red;\">\r\n  Version 2.1.0019 Pencil(铅笔) (2012-6-30)\r\n\r\n  <p>实现了由BA3CE建议的发送练习功能，并能够将练习时发送的文本记录下来；</p>\r\n  <p>新增加的频谱显示将频率坐标轴方向反向，即频率较低的数据显示在靠下的位置；</p>\r\n\r\n</li>\r\n\r\n<li>\r\n  Version 2.0.0018 Zongzi(粽子) (2012-6-22)\r\n\r\n  <p>正式引入FFT算法，大幅降低精确音频分析的CPU占用率；</p>\r\n  <p>基于CPU占用率的降低，默认的FFT（原DFT）采样数量增加为512（实际使用可以更高）；</p>\r\n  <p>增加了结合频率、时间、能量的频谱图；</p>\r\n  <p>修正了自动键的问题（感谢BG8ST及其他提出了此问题但没有留下呼号的朋友）</p>\r\n  <p>修正了“／”符号的Morse编码错误（感谢BD1GXH）；</p>\r\n  <p>修正了底层图形API(复制图层)的一个缺陷(过去有些控件显示可能会有拖尾无法擦净)；</p>\r\n  <p>从Lakey 2.0版本开始，Lakey版本中将去掉RELEASE/BETA标记，取而代之的将是为每一个新的版本赋予一个有趣的名字代号；</p>\r\n\r\n</li>\r\n\r\n<li>Version 1.1.0017 BETA (2010-8-15) \r\n \r\n<p>采样数默认值减至256每秒，以降低CPU使用率；</p>\r\n<p>接收音频完整数据分析（过去为抽样分析）；</p>\r\n<p>改进摩尔斯解析算法，增加对抖动的过滤，提高准确性(包括接收和发送)；</p>\r\n\r\n</li>\r\n\r\n<li>Version 1.1.0016 BETA (2010-8-14) \r\n \r\n<p>FFT计算精度由64位降低为32位，减少内存占用；</p>\r\n<p>优化了代码, 修正一些变量的类型, 避免过多类型转换；</p>\r\n<p>解决了按住空格画面显示错乱的问题；</p>\r\n<p>手册错字修正；</p>\r\n\r\n</li>\r\n\r\n<li>Version 1.1.0015 BETA (2010-8-12) \r\n \r\n<p>增加音量\\键速等控制旋钮及基础控件；</p>\r\n<p>网络通联自动识别记录对方IP地址, 这样只要发送放设置对方IP即可；</p>\r\n<p>取消精简模式(从初始版本一直以来的界面)；</p>\r\n<p>完善配置缺省值, 只要删除lakey.ini, 界面自动恢复为英文缺省界面；</p>\r\n\r\n</li>\r\n\r\n<li>Version 1.1.0014 BETA (2010-8-2) \r\n \r\n<p>增加模拟干扰信号；</p>\r\n<p>界面文字完全可配置，并增加纯中文界面版本；</p>\r\n<p>更正版本序列；</p>\r\n\r\n</li>\r\n\r\n<li>Version 1.1.0013 BETA (2010-5-2) \r\n \r\n<p>频谱分析增加对数和线性标尺；</p>\r\n<p>频谱分析窗口样式改进；</p>\r\n<p>改进了频谱分析状态提示；</p>\r\n\r\n</li>\r\n\r\n<li>Version 1.1.0012 BETA (2010-4-17) \r\n \r\n<p>修正了没有处理Win32消息返回值的错误，解决屏幕闪动的问题；</p>\r\n<p>修正了当发送队列不为空时退出有时报错的问题；</p>\r\n<p>增加了黑色；</p>\r\n\r\n</li>\r\n\r\n<li>Version 1.1.0011 BETA (2010-4-14) \r\n \r\n<p>增加了自动键模拟功能；</p>\r\n<p>波形和频谱分析按比例完全显示(过去显示不全)；</p>\r\n<p>波形显示可放大幅度(鼠标左键切换)；</p>\r\n<p>频谱分析可按线性和对数两种方式显示(鼠标右键切换)；</p>\r\n<p>修正了DCT采样数量小于频谱分析控件宽度时报错的问题。</p>\r\n\r\n</li>\r\n\r\n<li>Version 1.1.0010 BETA (2010-4-5) \r\n \r\n<p>增加了对网络通联的支持；</p>\r\n<p>标准控件改用系统主题风格(Windows XP版本以上)；</p>\r\n<p>加粗摩尔斯码记录条。</p>\r\n \r\n</li>\r\n \r\n<li>Version 1.0.0009 BETA (2009-11-22) \r\n \r\n<p>增加了设置wpm值的功能, 同时提供从复杂参数到wpm的反算功能；</p>\r\n<p>增加了对硬件端口输出额外的控制，可使硬件端口只在需要的时候输出；</p>\r\n<p>使用手册改为HTML格式。</p>\r\n \r\n</li>\r\n \r\n<li>Version 1.0.0008 BETA (2007-11-6) \r\n \r\n<p>增加了通过并行端口对外部设备进行控制的功能；</p>\r\n<p>更新了用户手册。</p>\r\n \r\n</li>\r\n \r\n<li>Version 1.0.0007 RELEASE (2007-10-30) \r\n \r\n<p>修正了KOCH训练模式下，正常结束后不能再次启动训练模式的问题；</p>\r\n<p>第一个稳定版本。</p>\r\n \r\n</li>\r\n \r\n<li>Version 1.0.0006 BETA (2007-7-10) \r\n \r\n<p>增加生成KOCH训练CW音频文件功能；</p>\r\n<p>增加生成任意字符串CW音频文件功能；</p>\r\n<p>改进分段、空格策略。</p>\r\n \r\n</li>\r\n \r\n<li>Version 1.0.0005 BETA (2007-3-29)\r\n<p>使用红色实时标记Koch模式训练时输入的错码；</p>\r\n<p>增加Koch模式训练统计功能。</p>\r\n \r\n</li>\r\n \r\n<li>Version 1.0.0004 BETA (2007-3-28)\r\n<p>取得《中华人民共和国业余无线电台执照》及呼号特别纪念^_^；</p>\r\n<p>增加Koch CW训练功能；</p>\r\n<p>帮助文档中增加3篇有关CW学习方法的文章；</p>\r\n<p>调整菜单布局。</p>\r\n \r\n</li>\r\n \r\n<li>Version 1.0.0003 BETA (2006-9-1)\r\n<p>增加了参数配置界面；</p>\r\n<p>增加了可以调整的音频分析精度；</p>\r\n<p>增加了CHM版本的用户手册。</p>\r\n \r\n</li>\r\n \r\n<li>Version 1.0.0002 BETA (2006-8-28)\r\n<p>增加了发送暂停功能；</p>\r\n<p>增加了发送文本文件(只包含Morse code中的英文/数字/标点)；</p>\r\n<p>增加了发送队列的长度到8192；</p>\r\n<p>修正了发送队列与显示不同步的问题。</p>\r\n \r\n</li>\r\n \r\n<li>Version 1.0.0001 BETA (2006-8-27)\r\n<p>初始版本。</p>\r\n \r\n</li>\r\n \r\n</body>\r\n</html>\r\n\r\n"
  },
  {
    "path": "src/CommFunc.cpp",
    "content": "#include \"stdafx.h\"\r\n#include \"Lakey.h\"\r\n#include \"windows.h\"\r\n#include \"Richedit.h\"\r\n#include \"commctrl.h\"\r\n#include <time.h>\r\n#include <ctype.h>\r\n\r\n#include \"LakeyMainWindow.h\"\r\n#include \"CommFunc.h\"\r\n\r\nBOOL GetDlgItemTxt(HWND hDlg, int nItemId, LPSTR lpTxtBuf, int nMaxLen)\r\n{\r\n\tif (GetDlgItem(hDlg, nItemId))\r\n\t{\r\n\t\tGetDlgItemText(hDlg, nItemId, lpTxtBuf, nMaxLen);\r\n\t\treturn TRUE;\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nBOOL SetDlgItemDec(HWND hDlg, UINT nItemId, double val)\r\n{\r\n\tif (GetDlgItem(hDlg, nItemId))\r\n\t{\r\n\t\tchar vBuff[32]; vBuff[sizeof(vBuff) - 1] = '\\0';\r\n\t\tsprintf(vBuff, \"%.4lf\", val);\r\n\t\tSetDlgItemText(hDlg, nItemId, vBuff);\r\n\t\treturn TRUE;\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nBOOL GetDlgItemDec(HWND hDlg, UINT nItemId, double* pVal)\r\n{\r\n\tif (GetDlgItem(hDlg, nItemId))\r\n\t{\r\n\t\tchar vBuff[32]; vBuff[sizeof(vBuff) - 1] = '\\0';\r\n\t\tGetDlgItemText(hDlg, nItemId, vBuff, sizeof(vBuff) - 1);\r\n\t\tsscanf(vBuff, \"%lf\", pVal);\r\n\t\treturn TRUE;\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nBOOL SetDlgItemHex(HWND hDlg, UINT nItemId, BYTE val)\r\n{\r\n\tif (GetDlgItem(hDlg, nItemId))\r\n\t{\r\n\t\tchar vBuff[32]; vBuff[sizeof(vBuff) - 1] = '\\0';\r\n\t\tsprintf(vBuff, \"%2.2hX\", val);\r\n\t\tSetDlgItemText(hDlg, nItemId, vBuff);\r\n\t\treturn TRUE;\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nBOOL GetDlgItemHex(HWND hDlg, UINT nItemId, BYTE* pVal)\r\n{\r\n\tif (GetDlgItem(hDlg, nItemId))\r\n\t{\r\n\t\tchar vBuff[32]; vBuff[sizeof(vBuff) - 1] = '\\0';\r\n\t\tGetDlgItemText(hDlg, nItemId, vBuff, sizeof(vBuff) - 1);\r\n\t\tWORD w = 0;\r\n\t\tsscanf(vBuff, \"%hX\", &w);\r\n\t\t*pVal = (BYTE)w;\r\n\t\treturn TRUE;\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nBOOL SetDlgItemHex(HWND hDlg, UINT nItemId, WORD val)\r\n{\r\n\tif (GetDlgItem(hDlg, nItemId))\r\n\t{\r\n\t\tchar vBuff[32]; vBuff[sizeof(vBuff) - 1] = '\\0';\r\n\t\tsprintf(vBuff, \"%4.4hX\", val);\r\n\t\tSetDlgItemText(hDlg, nItemId, vBuff);\r\n\t\treturn TRUE;\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nBOOL GetDlgItemHex(HWND hDlg, UINT nItemId, WORD* pVal)\r\n{\r\n\tif (GetDlgItem(hDlg, nItemId))\r\n\t{\r\n\t\tchar vBuff[32]; vBuff[sizeof(vBuff) - 1] = '\\0';\r\n\t\tGetDlgItemText(hDlg, nItemId, vBuff, sizeof(vBuff) - 1);\r\n\t\tsscanf(vBuff, \"%hX\", pVal);\r\n\t\treturn TRUE;\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nBOOL GetDlgItemInt(HWND hDlg, UINT nItemId, int* pVal)\r\n{\r\n\tif (GetDlgItem(hDlg, nItemId))\r\n\t{\r\n\t\tchar vBuff[32]; vBuff[sizeof(vBuff) - 1] = '\\0';\r\n\t\tGetDlgItemText(hDlg, nItemId, vBuff, sizeof(vBuff) - 1);\r\n\t\tsscanf(vBuff, \"%d\", pVal);\r\n\t\treturn TRUE;\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\n"
  },
  {
    "path": "src/CommFunc.h",
    "content": "#pragma once\r\n\r\n#include \"stdlib.h\"\r\n\r\nBOOL GetDlgItemTxt(HWND hDlg, int nItemId, LPSTR lpTxtBuf, int nMaxLen);\r\nBOOL SetDlgItemDec(HWND hDlg, UINT nItemId, double val);\r\nBOOL GetDlgItemDec(HWND hDlg, UINT nItemId, double* pVal);\r\nBOOL SetDlgItemHex(HWND hDlg, UINT nItemId, BYTE val);\r\nBOOL GetDlgItemHex(HWND hDlg, UINT nItemId, BYTE* pVal);\r\nBOOL SetDlgItemHex(HWND hDlg, UINT nItemId, WORD val);\r\nBOOL GetDlgItemHex(HWND hDlg, UINT nItemId, WORD* pVal);\r\nBOOL GetDlgItemInt(HWND hDlg, UINT nItemId, int* pVal);\r\n\r\n"
  },
  {
    "path": "src/EventListener.cpp",
    "content": "#include \"StdAfx.h\"\r\n#include \"EventListener.h\"\r\n"
  },
  {
    "path": "src/EventListener.h",
    "content": "#pragma once\r\n\r\n#include \"Graphics.h\"\r\n\r\nclass IEventListener\r\n{\r\n};\r\n\r\nclass IClickEventListener\r\n{\r\npublic:\r\n\tvirtual BOOL OnClick(void* owner) = 0;\r\n};\r\n\r\nclass IPaintEventListener\r\n{\r\npublic:\r\n//\tvirtual BOOL OnErase(void* owner, CGraphics* g, const RECT* pRect) = 0;\r\n\tvirtual BOOL OnPaint(void* owner, CGraphics* g, const RECT* pRect) = 0;\r\n};\r\n\r\nclass IMouseMoveEventListener\r\n{\r\npublic:\r\n\tvirtual BOOL OnMouseMove(void* owner, int x, int y) = 0;\r\n};\r\n\r\nclass IKeyboardEventListener : public IClickEventListener\r\n{\r\npublic:\r\n\tvirtual BOOL OnKeyDown(void* owner, int nKeyCode) = 0;\r\n\tvirtual BOOL OnKeyUp(void* owner, int nKeyCode) = 0;\r\n};\r\n\r\nclass IMouseKeyEventListener : public IClickEventListener\r\n{\r\npublic:\r\n\ttypedef enum { LBUTTON = 1, CBUTTON, RBUTTON } MouseKeyType;\r\n\r\npublic:\r\n\tvirtual BOOL OnMouseKeyDown(void* owner, MouseKeyType nMkt, int x, int y) = 0;\r\n\tvirtual BOOL OnMouseKeyUp(void* owner, MouseKeyType nMkt, int x, int y) = 0;\r\n};\r\n\r\nclass ITimerEventListener\r\n{\r\npublic:\r\n\tvirtual BOOL OnTimer(void* owner, int nTimerId) = 0;\r\n};\r\n\r\nclass ICommandEventListener\r\n{\r\npublic:\r\n\tvirtual BOOL OnCommand(void* owner, int nCommId) = 0;\r\n};\r\n\r\n"
  },
  {
    "path": "src/EventManagerWin32.cpp",
    "content": "#include \"StdAfx.h\"\r\n#include \"eventmanagerwin32.h\"\r\n\r\nCEventDispatcherWin32::CEventDispatcherWin32(HWND hWnd)\r\n{\r\n\tm_hWnd = hWnd;\r\n\tm_pGraphics = new CGraphics(hWnd);\r\n}\r\n\r\nCEventDispatcherWin32::~CEventDispatcherWin32(void)\r\n{\r\n\tdelete m_pGraphics;\r\n}\r\n\r\nBOOL CEventDispatcherWin32::OnMessage(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult)\r\n{\r\n\tBOOL r = FALSE;\r\n\r\n\tswitch (message) \r\n\t{\r\n\t\tcase WM_ERASEBKGND:\r\n\t\t\tr = EraseProc(); break;\r\n\t\tcase WM_PAINT:\r\n\t\t\tr = PaintProc(); break;\r\n\t\tcase WM_MOUSEMOVE:\r\n\t\t\tr = MouseMoveProc(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); break;\r\n\t\tcase WM_KEYDOWN:\r\n\t\t\tr = KeyDownProc((int)wParam); break;\r\n\t\tcase WM_KEYUP:\r\n\t\t\tr = KeyUpProc((int)wParam); break;\r\n\t\tcase WM_LBUTTONDOWN:\r\n\t\t\tr = MouseKeyDownProc(IMouseKeyEventListener::LBUTTON, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); break;\r\n\t\tcase WM_LBUTTONUP:\r\n\t\t\tr = MouseKeyUpProc(IMouseKeyEventListener::LBUTTON, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); break;\r\n\t\tcase WM_RBUTTONDOWN:\r\n\t\t\tr = MouseKeyDownProc(IMouseKeyEventListener::RBUTTON, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); break;\r\n\t\tcase WM_RBUTTONUP:\r\n\t\t\tr = MouseKeyUpProc(IMouseKeyEventListener::RBUTTON, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); break;\r\n\t\tcase WM_TIMER:\r\n\t\t\tr = TimerProc((int)wParam); break;\r\n\t\tcase WM_COMMAND:\r\n\t\t{\r\n\t\t\tint nCtrlId = LOWORD(wParam);\r\n\t\t\tif (nCtrlId)\r\n\t\t\t\tr = CommandProc(nCtrlId);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\treturn r;\r\n}\r\n\r\nvoid CEventDispatcherWin32::AddPaintEventControl(IPaintEventControl* pCtrl)\r\n{\r\n\tm_oPaintEventControls.push_back(pCtrl);\r\n}\r\n\r\nvoid CEventDispatcherWin32::AddMouseMoveEventControl(IMouseMoveEventControl* pCtrl)\r\n{\r\n\tm_oMouseMoveEventControls.push_back(pCtrl);\r\n}\r\n\r\nvoid CEventDispatcherWin32::AddKeyboardEventControl(IKeyboardEventControl* pCtrl)\r\n{\r\n\tm_oKeyboardEventControls.push_back(pCtrl);\r\n}\r\n\r\nvoid CEventDispatcherWin32::AddMouseKeyEventControl(IMouseKeyEventControl* pCtrl)\r\n{\r\n\tm_oMouseKeyEventControls.push_back(pCtrl);\r\n}\r\n\r\nvoid CEventDispatcherWin32::AddTimerEventControl(ITimerEventControl* pCtrl, int nTimerId, int nInterval)\r\n{\r\n\tm_oTimerEventControls.push_back(pCtrl);\r\n\tSetTimer(m_hWnd, nTimerId, nInterval, NULL);\r\n}\r\n\r\nvoid CEventDispatcherWin32::AddCommandEventControl(ICommandEventControl* pCtrl)\r\n{\r\n\tm_oCommandEventControls.push_back(pCtrl);\r\n}\r\n\r\nvoid CEventDispatcherWin32::RemovePaintEventControl(IPaintEventControl* pCtrl)\r\n{\r\n\tfor (vector<IPaintEventControl *>::iterator it = m_oPaintEventControls.begin();\r\n\t\tit != m_oPaintEventControls.end();\r\n\t\t++it)\r\n\t{\r\n\t\tif (pCtrl == (*it))\r\n\t\t{\r\n\t\t\tm_oPaintEventControls.erase(it);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid CEventDispatcherWin32::RemoveMouseMoveEventControl(IMouseMoveEventControl* pCtrl)\r\n{\r\n\tfor (vector<IMouseMoveEventControl *>::iterator it = m_oMouseMoveEventControls.begin();\r\n\t\tit != m_oMouseMoveEventControls.end();\r\n\t\t++it)\r\n\t{\r\n\t\tif (pCtrl == (*it))\r\n\t\t{\r\n\t\t\tm_oMouseMoveEventControls.erase(it);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid CEventDispatcherWin32::RemoveKeyboardEventControl(IKeyboardEventControl* pCtrl)\r\n{\r\n\tfor (vector<IKeyboardEventControl *>::iterator it = m_oKeyboardEventControls.begin();\r\n\t\tit != m_oKeyboardEventControls.end();\r\n\t\t++it)\r\n\t{\r\n\t\tif (pCtrl == (*it))\r\n\t\t{\r\n\t\t\tm_oKeyboardEventControls.erase(it);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid CEventDispatcherWin32::RemoveMouseKeyEventControl(IMouseKeyEventControl* pCtrl)\r\n{\r\n\tfor (vector<IMouseKeyEventControl *>::iterator it = m_oMouseKeyEventControls.begin();\r\n\t\tit != m_oMouseKeyEventControls.end();\r\n\t\t++it)\r\n\t{\r\n\t\tif (pCtrl == (*it))\r\n\t\t{\r\n\t\t\tm_oMouseKeyEventControls.erase(it);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid CEventDispatcherWin32::RemoveTimerEventControl(ITimerEventControl* pCtrl)\r\n{\r\n\tfor (vector<ITimerEventControl *>::iterator it = m_oTimerEventControls.begin();\r\n\t\tit != m_oTimerEventControls.end();\r\n\t\t++it)\r\n\t{\r\n\t\tif (pCtrl == (*it))\r\n\t\t{\r\n\t\t\tm_oTimerEventControls.erase(it);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid CEventDispatcherWin32::RemoveCommandEventControl(ICommandEventControl* pCtrl)\r\n{\r\n\tfor (vector<ICommandEventControl *>::iterator it = m_oCommandEventControls.begin();\r\n\t\tit != m_oCommandEventControls.end();\r\n\t\t++it)\r\n\t{\r\n\t\tif (pCtrl == (*it))\r\n\t\t{\r\n\t\t\tm_oCommandEventControls.erase(it);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid CEventDispatcherWin32::Invalidate(const RECT* pRect)\r\n{\r\n\t::InvalidateRect(m_hWnd, pRect, TRUE);\r\n}\r\n\r\nCGraphics* CEventDispatcherWin32::NewGraphics(int w, int h)\r\n{\r\n\tHDC hDc = GetDC(m_hWnd);\r\n\tCGraphics* g = new CGraphics(hDc, w, h);\r\n\tReleaseDC(m_hWnd, hDc);\r\n\treturn g;\r\n}\r\n\r\nBOOL CEventDispatcherWin32::EraseProc()\r\n{\r\n//\tm_pGraphics->SetErase();\r\n\treturn TRUE;\r\n}\r\n\r\nBOOL CEventDispatcherWin32::PaintProc()\r\n{\r\n\tBOOL r = FALSE;\r\n\tm_pGraphics->BeginPaint();\r\n\tfor (vector<IPaintEventControl *>::iterator it = m_oPaintEventControls.begin();\r\n\t\tit != m_oPaintEventControls.end();\r\n\t\t++it)\r\n\t{\r\n\t\tRECT cr, dr;\r\n\t\t(*it)->GetRect(&cr);\r\n\t\tconst RECT* pRect = m_pGraphics->GetPaintRect();\r\n\t\tif (NULL == pRect || IntersectRect(&dr, pRect, &cr))\r\n\t\t{\r\n\t\t\tOffsetRect(&dr, -cr.left, -cr.top);\r\n\t\t\tm_pGraphics->SetOrigin(cr.left, cr.top);\r\n\t\t\tr |= (*it)->OnPaint((*it), m_pGraphics, &dr);\r\n\t\t}\r\n\t}\r\n\tm_pGraphics->EndPaint();\r\n\r\n\treturn r;\r\n}\r\n\r\nBOOL CEventDispatcherWin32::MouseMoveProc(int x, int y)\r\n{\r\n\tBOOL r = FALSE;\r\n\tfor (vector<IMouseMoveEventControl *>::iterator it = m_oMouseMoveEventControls.begin();\r\n\t\tit != m_oMouseMoveEventControls.end();\r\n\t\t++it)\r\n\t{\r\n\t\tif ((*it)->IsRelated(x, y))\r\n\t\t{\r\n\t\t\tRECT cr;\r\n\t\t\t(*it)->GetRect(&cr);\r\n\t\t\tr |= (*it)->OnMouseMove((*it), x - cr.left, y - cr.top);\r\n\t\t}\r\n\t}\r\n\r\n\treturn r;\r\n}\r\n\r\nBOOL CEventDispatcherWin32::KeyDownProc(int nKeyCode)\r\n{\r\n\tBOOL r = FALSE;\r\n\tfor (vector<IKeyboardEventControl *>::iterator it = m_oKeyboardEventControls.begin();\r\n\t\tit != m_oKeyboardEventControls.end();\r\n\t\t++it)\r\n\t{\r\n\t\tr |= (*it)->OnKeyDown((*it), nKeyCode);\r\n\t}\r\n\r\n\treturn r;\r\n}\r\n\r\nBOOL CEventDispatcherWin32::KeyUpProc(int nKeyCode)\r\n{\r\n\tBOOL r = FALSE;\r\n\tfor (vector<IKeyboardEventControl *>::iterator it = m_oKeyboardEventControls.begin();\r\n\t\tit != m_oKeyboardEventControls.end();\r\n\t\t++it)\r\n\t{\r\n\t\tr |= (*it)->OnKeyUp((*it), nKeyCode);\r\n\t}\r\n\r\n\treturn r;\r\n}\r\n\r\nBOOL CEventDispatcherWin32::MouseKeyDownProc(IMouseKeyEventControl::MouseKeyType nMkt, int x, int y)\r\n{\r\n\tBOOL r = FALSE;\r\n\tfor (vector<IMouseKeyEventControl *>::iterator it = m_oMouseKeyEventControls.begin();\r\n\t\tit != m_oMouseKeyEventControls.end();\r\n\t\t++it)\r\n\t{\r\n\t\tif ((*it)->IsRelated(x, y))\r\n\t\t{\r\n\t\t\tRECT cr;\r\n\t\t\t(*it)->GetRect(&cr);\r\n\t\t\tr |= (*it)->OnMouseKeyDown((*it), nMkt, x - cr.left, y - cr.top);\r\n\t\t}\r\n\t}\r\n\r\n\treturn r;\r\n}\r\n\r\nBOOL CEventDispatcherWin32::MouseKeyUpProc(IMouseKeyEventListener::MouseKeyType nMkt, int x, int y)\r\n{\r\n\tBOOL r = FALSE;\r\n\tfor (vector<IMouseKeyEventControl *>::iterator it = m_oMouseKeyEventControls.begin();\r\n\t\tit != m_oMouseKeyEventControls.end();\r\n\t\t++it)\r\n\t{\r\n\t\tif ((*it)->IsRelated(x, y))\r\n\t\t{\r\n\t\t\tRECT cr;\r\n\t\t\t(*it)->GetRect(&cr);\r\n\t\t\tr |= (*it)->OnMouseKeyUp((*it), nMkt, x - cr.left, y - cr.top);\r\n\t\t}\r\n\t}\r\n\r\n\treturn r;\r\n}\r\n\r\nBOOL CEventDispatcherWin32::TimerProc(int nTimerId)\r\n{\r\n\tBOOL r = FALSE;\r\n\tfor (vector<ITimerEventControl *>::iterator it = m_oTimerEventControls.begin();\r\n\t\tit != m_oTimerEventControls.end();\r\n\t\t++it)\r\n\t{\r\n\t\tr |= (*it)->OnTimer((*it), nTimerId);\r\n\t}\r\n\r\n\treturn r;\r\n}\r\n\r\nBOOL CEventDispatcherWin32::CommandProc(int nCommId)\r\n{\r\n\tBOOL r = FALSE;\r\n\tfor (vector<ICommandEventControl *>::iterator it = m_oCommandEventControls.begin();\r\n\tit != m_oCommandEventControls.end();\r\n\t\t++it)\r\n\t{\r\n\t\tr |= (*it)->OnCommand((*it), nCommId);\r\n\t}\r\n\r\n\treturn r;\r\n}\r\n\r\nBOOL IControl::PointInRect(const RECT* pRect, int x, int y)\r\n{\r\n\tPOINT pt;\r\n\tpt.x = x;\r\n\tpt.y = y;\r\n\r\n\treturn ::PtInRect(pRect, pt);\r\n}\r\n\r\nBOOL IControl::IntersectRect(RECT* pDest, const RECT* pSrc1, const RECT* pSrc2)\r\n{\r\n\treturn ::IntersectRect(pDest, pSrc1, pSrc2);\r\n}\r\n\r\n\r\n"
  },
  {
    "path": "src/EventManagerWin32.h",
    "content": "#pragma once\r\n\r\n#include <vector>\r\n\r\n#include \"Graphics.h\"\r\n#include \"EventListener.h\"\r\n\r\nusing namespace std;\r\n\r\nclass IControl\r\n{\r\npublic:\r\n\tvirtual BOOL IsRelated(int x, int y) = 0;\r\n\tvirtual void GetRect(RECT* r) = 0;\r\n\r\n\tstatic BOOL PointInRect(const RECT* pRect, int x, int y);\r\n\tstatic BOOL IntersectRect(RECT* pDest, const RECT* pSrc1, const RECT* pSrc2);\r\n};\r\n\r\nclass IPaintEventControl : public IControl, public IPaintEventListener\r\n{\r\n};\r\n\r\nclass IMouseMoveEventControl : public IControl, public IMouseMoveEventListener\r\n{\r\n};\r\n\r\nclass IKeyboardEventControl : public IKeyboardEventListener\r\n{\r\n};\r\n\r\nclass IMouseKeyEventControl : public IControl, public IMouseKeyEventListener\r\n{\r\n};\r\n\r\nclass ITimerEventControl : public ITimerEventListener\r\n{\r\n};\r\n\r\nclass ICommandEventControl : public ICommandEventListener\r\n{\r\n};\r\n\r\nclass IUserData\r\n{\r\npublic:\r\n\tvirtual void SetUserData(void* pUserData) = 0;\r\n\tvirtual void* GetUserData() = 0;\r\n};\r\n\r\nclass IPaintableParent\r\n{\r\npublic:\r\n\tvirtual void Invalidate(const RECT* pRect) = 0;\r\n\tvirtual CGraphics* NewGraphics(int w, int h) = 0;\r\n};\r\n\r\nclass CEventDispatcherWin32\r\n\t: public IPaintableParent\r\n{\r\npublic:\r\n\tCEventDispatcherWin32(HWND hWnd);\r\n\tvirtual ~CEventDispatcherWin32(void);\r\n\r\n\tvirtual BOOL OnMessage(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult);\r\n\r\n\tvirtual void AddPaintEventControl(IPaintEventControl* pCtrl);\r\n\tvirtual void AddMouseMoveEventControl(IMouseMoveEventControl* pCtrl);\r\n\tvirtual void AddKeyboardEventControl(IKeyboardEventControl* pCtrl);\r\n\tvirtual void AddMouseKeyEventControl(IMouseKeyEventControl* pCtrl);\r\n\tvirtual void AddTimerEventControl(ITimerEventControl* pCtrl, int nTimerId, int nInterval);\r\n\tvirtual void AddCommandEventControl(ICommandEventControl* pCtrl);\r\n\r\n\tvirtual void Invalidate(const RECT* pRect);\r\n\tvirtual CGraphics* NewGraphics(int w, int h);\r\n\r\n\tvirtual BOOL EraseProc();\r\n\tvirtual BOOL PaintProc();\r\n\tvirtual BOOL MouseMoveProc(int x, int y);\r\n\tvirtual BOOL KeyDownProc(int nKeyCode);\r\n\tvirtual BOOL KeyUpProc(int nKeyCode);\r\n\tvirtual BOOL MouseKeyDownProc(IMouseKeyEventListener::MouseKeyType nMkt, int x, int y);\r\n\tvirtual BOOL MouseKeyUpProc(IMouseKeyEventListener::MouseKeyType nMkt, int x, int y);\r\n\tvirtual BOOL TimerProc(int nTimerId);\r\n\tvirtual BOOL CommandProc(int nCommId);\r\n\r\n\tvirtual void RemovePaintEventControl(IPaintEventControl* pCtrl);\r\n\tvirtual void RemoveMouseMoveEventControl(IMouseMoveEventControl* pCtrl);\r\n\tvirtual void RemoveKeyboardEventControl(IKeyboardEventControl* pCtrl);\r\n\tvirtual void RemoveMouseKeyEventControl(IMouseKeyEventControl* pCtrl);\r\n\tvirtual void RemoveTimerEventControl(ITimerEventControl* pCtrl);\r\n\tvirtual void RemoveCommandEventControl(ICommandEventControl* pCtrl);\r\n\r\nprotected:\r\n\tHWND GetHWnd() { return m_hWnd; };\r\n\tCGraphics* GetGraphics() { return m_pGraphics; };\r\n\r\nprivate:\r\n\tvector<IPaintEventControl *>\t\tm_oPaintEventControls;\r\n\tvector<IMouseMoveEventControl *>\tm_oMouseMoveEventControls;\r\n\tvector<IKeyboardEventControl *>\t\tm_oKeyboardEventControls;\r\n\tvector<IMouseKeyEventControl *>\t\tm_oMouseKeyEventControls;\r\n\tvector<ITimerEventControl *>\t\tm_oTimerEventControls;\r\n\tvector<ICommandEventControl *>\t\tm_oCommandEventControls;\r\n\r\n\tCGraphics*\t\tm_pGraphics;\r\n\tHWND\t\t\tm_hWnd;\r\n};\r\n\r\n"
  },
  {
    "path": "src/FFT.cpp",
    "content": "#include \"StdAfx.h\"\r\n#include \"fft.h\"\r\n#include <complex>\r\n"
  },
  {
    "path": "src/FFT.h",
    "content": "#pragma once\r\n\r\n#include <math.h>\r\n\r\n#ifdef PI\r\n#undef PI\r\n#endif\r\n\r\n#define PI\t\t3.1415926f\r\n\r\n/**\r\n * class T: unit of external stored\r\n * class V: unit of internal handled\r\n */\r\n\r\ntemplate <class T, class V> class IFilterDFT\r\n{\r\npublic:\r\n\tvirtual T OnEncodeFilter(V val, int i) = 0;\r\n\tvirtual T OnDecodeFilter(V val, int i) = 0;\r\n};\r\n\r\ntemplate <class T, class V> class TCosDFT\r\n{\r\npublic:\r\n\tTCosDFT(int nAnalyzeSamples, IFilterDFT<T, V>* pFilter = NULL);\r\n\t~TCosDFT(void);\r\n\tvoid Encode(T* pDest, const T* pSrc);\r\n\tvoid Decode(T* pDest, const T* pSrc);\r\n\r\nprivate:\r\n\tint\t\t\tm_nAnalyzeSamples;\r\n\tV**\tm_ppCosTab;\r\n\tIFilterDFT<T, V>* m_pFilter;\r\n};\r\n\r\ntemplate <class T, class V> class TSinDFT\r\n{\r\npublic:\r\n\tTSinDFT(int nAnalyzeSamples, IFilterDFT<T, V>* pFilter = NULL);\r\n\t~TSinDFT(void);\r\n\tvoid Encode(T* pDest, const T* pSrc);\r\n\tvoid Decode(T* pDest, const T* pSrc);\r\n\r\nprivate:\r\n\tint\t\t\tm_nAnalyzeSamples;\r\n\tV**\tm_ppSinTab;\r\n\tIFilterDFT<T, V>* m_pFilter;\r\n};\r\n\r\ntemplate <class T, class V> class TFastFT\r\n{\r\npublic:\r\n\tTFastFT(int nAnalyzeSamples, IFilterDFT<T, V>* pFilter = NULL);\r\n\t~TFastFT(void);\r\n\tvoid Encode(T* pDest, const T* pSrc);\r\n\tvoid Decode(T* pDest, const T* pSrc);\r\n\r\nprivate:\r\n\tvoid\t\tfftCore();\r\n\tint\t\t\tm_nAnalyzeSamples;\r\n\tint\t\t\tm_nLog2;\r\n\tV*\t\t\tm_vBuf[2];\r\n\r\n\tIFilterDFT<T, V>* m_pFilter;\r\n};\r\n\r\ntemplate <class T, class V> \r\nTFastFT<T, V>::TFastFT(int nAnalyzeSamples, IFilterDFT<T, V>* pFilter/* = NULL*/)\r\n{\r\n\tm_nAnalyzeSamples = nAnalyzeSamples;\r\n\tm_pFilter = pFilter;\r\n\tm_vBuf[0] = new V[m_nAnalyzeSamples];\t// real\r\n\tm_vBuf[1] = new V[m_nAnalyzeSamples];\t// imod\r\n\r\n\tfor (m_nLog2 = 0; nAnalyzeSamples > 1; ++m_nLog2)\r\n\t{\r\n\t\tnAnalyzeSamples >>= 1;\r\n\t}\r\n}\r\n\r\ntemplate <class T, class V> \r\nTFastFT<T, V>::~TFastFT(void)\r\n{\r\n\tdelete[] m_vBuf[0];\r\n\tdelete[] m_vBuf[1];\r\n}\r\n\r\ntemplate <class T, class V> \r\nTCosDFT<T, V>::TCosDFT(int nAnalyzeSamples, IFilterDFT<T, V>* pFilter/* = NULL*/)\r\n{\r\n\tm_nAnalyzeSamples = nAnalyzeSamples;\r\n\tm_ppCosTab = new V*[m_nAnalyzeSamples];\r\n\tm_pFilter = pFilter;\r\n\r\n\tfor (int i = 0; i < m_nAnalyzeSamples; ++i)\r\n\t{\r\n\t\tm_ppCosTab[i] = new V[m_nAnalyzeSamples];\r\n\r\n\t\tfor (int x = 0; x < m_nAnalyzeSamples; ++x)\r\n\t\t\tm_ppCosTab[i][x] = cos(((x * 2) + 1) * i * PI / (2 * m_nAnalyzeSamples));\r\n\t}\r\n}\r\n\r\ntemplate <class T, class V> \r\nTCosDFT<T, V>::~TCosDFT(void)\r\n{\r\n\tfor (int i = 0; i < m_nAnalyzeSamples; ++i)\r\n\t\tdelete[] m_ppCosTab[i];\r\n\r\n\tdelete[] m_ppCosTab;\r\n}\r\n\r\ntemplate <class T, class V> \r\nTSinDFT<T, V>::TSinDFT(int nAnalyzeSamples, IFilterDFT<T, V>* pFilter/* = NULL*/)\r\n{\r\n\tm_nAnalyzeSamples = nAnalyzeSamples;\r\n\tm_ppSinTab = new V*[m_nAnalyzeSamples];\r\n\tm_pFilter = pFilter;\r\n\r\n\tfor (int i = 0; i < m_nAnalyzeSamples; ++i)\r\n\t{\r\n\t\tm_ppSinTab[i] = new V[m_nAnalyzeSamples];\r\n\r\n\t\tfor (int x = 0; x < m_nAnalyzeSamples; ++x)\r\n\t\t\tm_ppSinTab[i][x] = sin(((x * 2) + 1) * i * PI / (2 * m_nAnalyzeSamples));\r\n\t}\r\n}\r\n\r\ntemplate <class T, class V> \r\nTSinDFT<T, V>::~TSinDFT(void)\r\n{\r\n\tfor (int i = 0; i < m_nAnalyzeSamples; ++i)\r\n\t\tdelete[] m_ppSinTab[i];\r\n\r\n\tdelete[] m_ppSinTab;\r\n}\r\n\r\ntemplate <class T, class V> \r\nvoid TSinDFT<T, V>::Encode(T* pDest, const T* pSrc)\r\n{\r\n\tfor (int i = 0; i < m_nAnalyzeSamples; ++i)\r\n\t{\r\n\t\tV c = 0;\r\n\t\tfor (int x = 0; x < m_nAnalyzeSamples; ++x)\r\n\t\t{\r\n\t\t\tc += pSrc[x] * m_ppSinTab[i][x];\r\n\t\t}\r\n\t\tpDest[i] = m_pFilter ? m_pFilter->OnEncodeFilter(2 * c / m_nAnalyzeSamples, i) \r\n\t\t\t: (T)(2 * c / m_nAnalyzeSamples);\r\n\t}\r\n}\r\n\r\ntemplate <class T, class V> \r\nvoid TCosDFT<T, V>::Encode(T* pDest, const T* pSrc)\r\n{\r\n\tV s = 0;\r\n\tstatic int ddd = 100;\r\n\tfor (int i = 0; i < m_nAnalyzeSamples; ++i)\r\n\t{\r\n\t\tV c = 0;\r\n\t\tfor (int x = 0; x < m_nAnalyzeSamples; ++x)\r\n\t\t{\r\n\t\t\tc += pSrc[x] * m_ppCosTab[i][x];\r\n\t\t}\r\n\t\tpDest[i] = m_pFilter ? m_pFilter->OnEncodeFilter(2 * c / m_nAnalyzeSamples, i) \r\n\t\t\t: (T)(2 * c / m_nAnalyzeSamples);\r\n\r\n\t\ts += abs(pDest[i]);\r\n\t}\r\n\r\n\tif (!(0 != ddd || 1.0 < s))\r\n\t{\r\n\t\tddd = 0;\r\n\t}\r\n\r\n\tif (0 < ddd)\r\n\t\t--ddd;\r\n\r\n}\r\n\r\ntemplate <class T, class V> \r\nvoid TSinDFT<T, V>::Decode(T* pDest, const T* pSrc)\r\n{\r\n\tfor (int i = 0; i < m_nAnalyzeSamples; ++i)\r\n\t{\r\n\t\tV c = 0;\r\n\t\tfor (int x = 0; x < m_nAnalyzeSamples; ++x)\r\n\t\t{\r\n\t\t\tc += pSrc[x] * m_ppSinTab[i][x];\r\n\t\t}\r\n\t\tpDest[i] = m_pFilter ? m_pFilter->OnDecodeFilter(c, i) \r\n\t\t\t: (T)c;\r\n\t}\r\n}\r\n\r\ntemplate <class T, class V> \r\nvoid TCosDFT<T, V>::Decode(T* pDest, const T* pSrc)\r\n{\r\n\tfor (int i = 0; i < m_nAnalyzeSamples; ++i)\r\n\t{\r\n\t\tV c = 0;\r\n\t\tfor (int x = 0; x < m_nAnalyzeSamples; ++x)\r\n\t\t{\r\n\t\t\tc += pSrc[x] * m_ppCosTab[i][x];\r\n\t\t}\r\n\t\tpDest[i] = m_pFilter ? m_pFilter->OnDecodeFilter(c, i) \r\n\t\t\t: (T)c;\r\n\t}\r\n}\r\n\r\ntemplate <class T, class V> \r\nvoid TFastFT<T, V>::Encode(T* pDest, const T* pSrc)\r\n{\r\n\tfor (int i = 0; i < m_nAnalyzeSamples; ++i)\r\n\t{\r\n\t\tm_vBuf[0][i] = (V)pSrc[i];\r\n\t\tm_vBuf[1][i] = (V)0;\r\n\t}\r\n\r\n\tfftCore();\r\n\r\n\tint n = m_nAnalyzeSamples / 2;\r\n\tV x, y;\r\n\r\n\t// ֪ΪɶFFT任зֱʽһ룬ΪԳƣֲ\r\n\t// ԭƵ(LaWaveCapture)ʾֻҪȡһ뼴\r\n\tif (m_pFilter)\r\n\t{\r\n\t\tfor (int i = 0; i < n; ++i)\r\n\t\t{\r\n\t\t\tx = m_vBuf[0][i];\r\n\t\t\ty = m_vBuf[1][i];\r\n\t\t\t//pDest[i] = (T)m_vBuf[0][i];\r\n\t\t\tpDest[i * 2] = m_pFilter->OnEncodeFilter(sqrt(x * x + y * y), i * 2);\r\n\r\n\t\t\tx = m_vBuf[0][m_nAnalyzeSamples - i - 1];\r\n\t\t\ty = m_vBuf[1][m_nAnalyzeSamples - i - 1];\r\n\t\t\tpDest[i * 2 + 1] = m_pFilter->OnEncodeFilter(sqrt(x * x + y * y), i * 2 + 1);\r\n\t\t}\r\n\t}\r\n\telse\r\n\t{\r\n\t\tfor (int i = 0; i < m_nAnalyzeSamples; ++i)\r\n\t\t{\r\n\t\t\tx = m_vBuf[0][i];\r\n\t\t\ty = m_vBuf[1][i];\r\n\t\t\t//pDest[i] = (T)m_vBuf[0][i];\r\n\t\t\tpDest[i * 2] = sqrt(x * x + y * y);\r\n\r\n\t\t\tx = m_vBuf[0][m_nAnalyzeSamples - i - 1];\r\n\t\t\ty = m_vBuf[1][m_nAnalyzeSamples - i - 1];\r\n\t\t\tpDest[i * 2 + 1] = sqrt(x * x + y * y);\r\n\t\t}\r\n\t}\r\n}\r\n\r\ntemplate <class T, class V> \r\nvoid TFastFT<T, V>::Decode(T* pDest, const T* pSrc)\r\n{\r\n\tfor (int i = 0; i < m_nAnalyzeSamples; ++i)\r\n\t{\r\n\t\tm_vBuf[0][i] = (V)pSrc[i];\r\n\t\tm_vBuf[1][i] = (V)0;\r\n\t}\r\n\r\n\tfftCore();\r\n\r\n\tfor (int i = 0; i < m_nAnalyzeSamples; ++i)\r\n\t{\r\n\t\t//pDest[i] = (T)(m_vBuf[0][i] / m_nAnalyzeSamples);\r\n\t\tpDest[i] = m_pFilter ? m_pFilter->OnDecodeFilter((T)m_vBuf[0][i], i) \r\n\t\t\t: (T)m_vBuf[0][i];\r\n\t}\r\n}\r\n\r\ntemplate <class T, class V> \r\nvoid TFastFT<T, V>::fftCore()\r\n{\r\n\tint np, lmx, lix, nv2, npm1, lo, lm, li, j1, j2, i, j, k, l;\r\n\tV scl, arg, s, c, t1, t2;\r\n\r\n\tnp = m_nAnalyzeSamples;\r\n\tl = m_nLog2;\r\n\t\r\n\tlmx = np;\r\n\tscl = 2 * PI / np;\r\n\tfor (lo = 0; lo < l; ++lo)\r\n\t{\r\n\t\tlix = lmx;\r\n\t\tlmx = lmx / 2;\r\n\t\targ = 0;\r\n\t\tfor (lm = 0; lm < lmx; ++lm)\r\n\t\t{\r\n\t\t\tc = cos(arg);\r\n\t\t\ts = sin(arg);\r\n\t\t\targ = arg + scl;\r\n\t\t\tfor (li = lix; li <= np; li += lix)\r\n\t\t\t{\r\n\t\t\t\tj1 = li - lix + lm;\r\n\t\t\t\tj2 = j1 + lmx;\r\n\t\t\t\tt1 = m_vBuf[0][j1] - m_vBuf[0][j2];\r\n\t\t\t\tt2 = m_vBuf[1][j1] - m_vBuf[1][j2];\r\n\t\t\t\tm_vBuf[0][j1] += m_vBuf[0][j2];\r\n\t\t\t\tm_vBuf[1][j1] += m_vBuf[1][j2];\r\n\t\t\t\tm_vBuf[0][j2] = c * t1 + s * t2;\r\n\t\t\t\tm_vBuf[1][j2] = c * t2 - s * t1;\r\n\t\t\t} // for li\r\n\t\t} // for lm\r\n\r\n\t\tscl *= 2;\r\n\t} // for lo\r\n\r\n\tj = 0;\r\n\tnv2 = np / 2;\r\n\tnpm1 = np - 1;\r\n\tfor (i = 0; i < npm1; ++i)\r\n\t{\r\n\t\tif (i < j)\r\n\t\t{\r\n\t\t\tt1 = m_vBuf[0][j];\r\n\t\t\tt2 = m_vBuf[1][j];\r\n\t\t\tm_vBuf[0][j] = m_vBuf[0][i];\r\n\t\t\tm_vBuf[1][j] = m_vBuf[1][i];\r\n\t\t\tm_vBuf[0][i] = t1;\r\n\t\t\tm_vBuf[1][i] = t2;\r\n\t\t}\r\n\r\n\t\tk = nv2;\r\n\t\twhile(k - 1 < j)\r\n\t\t{\r\n\t\t\tj -= k;\r\n\t\t\tk /= 2;\r\n\t\t}\r\n\t\tj += k;\r\n\t}\r\n}"
  },
  {
    "path": "src/Graphics.cpp",
    "content": "#include \"StdAfx.h\"\r\n#include \"graphics.h\"\r\n#include \"stdio.h\"\r\n\r\nCGraphics::CGraphics(HWND hWnd)\r\n{\r\n\tm_hWnd = hWnd;\r\n\tGetClientRect(m_hWnd, &m_oSize);\r\n\tHDC hDc = GetDC(m_hWnd);\r\n\tm_hDc = ::CreateCompatibleDC(hDc);\r\n\tm_hBgBm = ::CreateCompatibleBitmap(hDc, m_oSize.right, m_oSize.bottom);\r\n\tSelectObject(m_hDc, m_hBgBm);\r\n\tReleaseDC(m_hWnd, hDc);\r\n\r\n\tSetOrigin(0, 0);\r\n\r\n\tm_nColor = RGB(0, 0, 0);\r\n\t//m_nBgColor = RGB(224, 224, 224);\r\n\tm_nBgColor = RGB(255, 255, 255);\r\n\r\n\tm_hPen = CreatePen(PS_SOLID, 1, m_nColor);\r\n\tm_hPenDot = CreatePen(PS_DASH, 1, m_nColor);\r\n\tm_hBrush = CreateSolidBrush(m_nBgColor);\r\n\r\n\tDrawRect(&m_oSize);\r\n//\tSetBkMode(m_hDc, TRANSPARENT);\r\n}\r\n\r\nCGraphics::CGraphics(HDC hParentDc, int w, int h)\r\n{\r\n\tm_oSize.left = m_oSize.top = 0;\r\n\tm_oSize.right = w;\r\n\tm_oSize.bottom = h;\r\n\r\n\tm_hWnd = NULL;\r\n\tm_hDc = ::CreateCompatibleDC(hParentDc);\r\n\tm_hBgBm = ::CreateCompatibleBitmap(hParentDc, m_oSize.right, m_oSize.bottom);\r\n\tSelectObject(m_hDc, m_hBgBm);\r\n\r\n\tSetOrigin(0, 0);\r\n\r\n\tm_nColor = RGB(0, 0, 0);\r\n\tm_nBgColor = RGB(255, 255, 255);\r\n\r\n\tm_hPen = ::CreatePen(PS_SOLID, 1, m_nColor);\r\n\tm_hPenDot = CreatePen(PS_DASH, 1, m_nColor);\r\n\tm_hBrush = ::CreateSolidBrush(m_nBgColor);\r\n\r\n//\tSetBkMode(m_hDc, TRANSPARENT);\r\n}\r\n\r\nCGraphics::~CGraphics(void)\r\n{\r\n\t::DeleteObject(m_hBrush);\r\n\t::DeleteObject(m_hPen);\r\n\t::DeleteObject(m_hPenDot);\r\n\t::DeleteObject(m_hBgBm);\r\n\r\n\tif (m_hDc)\r\n\t\t::DeleteDC(m_hDc);\r\n}\r\n\r\nvoid CGraphics::BeginPaint()\r\n{\r\n\tif (m_hWnd)\r\n\t{\r\n\t\tm_hWndDc = ::BeginPaint(m_hWnd, &m_ps);\r\n\t\t::SetBkMode(m_hDc, TRANSPARENT);\r\n\t}\r\n}\r\n\r\nvoid CGraphics::EndPaint()\r\n{\r\n\tif (m_hWnd)\r\n\t{\r\n\t\t//HDC hWndDc = ::BeginPaint(m_hWnd, &m_ps);\r\n\r\n\t\t::BitBlt( m_hWndDc, m_ps.rcPaint.left, m_ps.rcPaint.top\r\n\t\t\t, m_ps.rcPaint.right - m_ps.rcPaint.left, m_ps.rcPaint.bottom - m_ps.rcPaint.top\r\n\t\t\t, m_hDc, m_ps.rcPaint.left, m_ps.rcPaint.top, SRCCOPY);\r\n\r\n\t\t//printf(\"%d,%d,%d,%d\", m_ps.rcPaint.left, m_ps.rcPaint.right, m_ps.rcPaint.top, m_ps.rcPaint.bottom);\r\n/*\t\t\r\n\t\t::BitBlt( m_hWndDc, m_oSize.left, m_oSize.top\r\n\t\t\t, m_oSize.right - m_oSize.left, m_oSize.bottom - m_oSize.top\r\n\t\t\t, m_hDc, 0, 0, SRCCOPY);\r\n*/\r\n\t\t::EndPaint(m_hWnd, &m_ps);\r\n\t}\r\n}\r\n\r\nconst RECT* CGraphics::GetPaintRect()\r\n{\r\n\tif (m_hDc)\r\n\t\treturn &m_ps.rcPaint;\r\n\r\n\treturn NULL;\r\n}\r\n\r\nvoid CGraphics::SetOrigin(int x, int y)\r\n{\r\n\tm_nOriginX = x;\r\n\tm_nOriginY = y;\r\n}\r\n\r\nvoid CGraphics::SetColor(int rgb)\r\n{\r\n\tm_nColor = rgb;\r\n\t::DeleteObject(m_hPen);\r\n\t::DeleteObject(m_hPenDot);\r\n\tm_hPen = ::CreatePen(PS_SOLID, 1, m_nColor);\r\n\tm_hPenDot = ::CreatePen(PS_DOT, 1, m_nColor);\r\n}\r\n\r\nvoid CGraphics::SetBgColor(int rgb)\r\n{\r\n\tm_nBgColor = rgb;\r\n\tDeleteObject(m_hBrush);\r\n\tm_hBrush = CreateSolidBrush(m_nBgColor);\r\n\t::SetBkColor(m_hDc, rgb);\r\n}\r\n\r\nvoid CGraphics::DrawRoundRect(const RECT* pRect, int nEllipseWidth, int nEllipseHeight)\r\n{\r\n\t::SelectObject(m_hDc, m_hPen);\r\n\t::SelectObject(m_hDc, m_hBrush);\r\n\t::RoundRect(m_hDc, pRect->left + m_nOriginX, pRect->top + m_nOriginY, pRect->right + m_nOriginX, pRect->bottom + m_nOriginY, nEllipseWidth, nEllipseHeight);\r\n}\r\n\r\nvoid CGraphics::DrawEllipse(const RECT* pRect)\r\n{\r\n\t::SelectObject(m_hDc, m_hPen);\r\n\t::SelectObject(m_hDc, m_hBrush);\r\n\t::Ellipse(m_hDc, pRect->left + m_nOriginX, pRect->top + m_nOriginY, pRect->right + m_nOriginX, pRect->bottom + m_nOriginY);\r\n}\r\n\r\nvoid CGraphics::DrawText(const RECT* pRect, char* pText, int nFormat, BOOL bTransparent /* = NULL */)\r\n{\r\n\tif (bTransparent)\r\n\t{\r\n\t\tif (TRANSPARENT != ::GetBkMode(m_hDc))\r\n\t\t\t::SetBkMode(m_hDc, TRANSPARENT);\r\n\t}\r\n\telse\r\n\t{\r\n\t\tif (OPAQUE != ::GetBkMode(m_hDc))\r\n\t\t\t::SetBkMode(m_hDc, OPAQUE);\r\n\t}\r\n\r\n\t::SetTextColor(m_hDc, m_nColor);\r\n\tRECT r = *pRect;\r\n\t::OffsetRect(&r, m_nOriginX, m_nOriginY);\r\n\t::DrawText(m_hDc, pText, (int)strlen(pText), &r, nFormat);\r\n}\r\n\r\nvoid CGraphics::SetFont(CFont* pFont)\r\n{\r\n\tif (pFont)\r\n\t\t::SelectObject(m_hDc, pFont->GetFont());\r\n}\r\n\r\nvoid CGraphics::Copy(const RECT* pDestRect, CGraphics* pSrc, int x, int y)\r\n{\r\n\t::BitBlt( m_hDc, pDestRect->left + m_nOriginX, pDestRect->top + m_nOriginY\r\n\t\t, pDestRect->right - pDestRect->left, pDestRect->bottom - pDestRect->top\r\n\t\t, pSrc->m_hDc, x, y, SRCCOPY);\r\n}\r\n\r\nvoid CGraphics::DrawRect(const RECT* pRect)\r\n{\r\n\tRECT r = *pRect;\r\n\t::OffsetRect(&r, m_nOriginX, m_nOriginY);\r\n\t::FillRect(m_hDc, &r, m_hBrush);\r\n}\r\n\r\nvoid CGraphics::DrawLine(int x1, int y1, int x2, int y2)\r\n{\r\n\tBOOL r;\r\n\tHGDIOBJ old = ::SelectObject(m_hDc, m_hPen);\r\n\tr = ::MoveToEx(m_hDc, x1 + m_nOriginX, y1 + m_nOriginY, NULL);\r\n\tr = ::LineTo(m_hDc, x2 + m_nOriginX, y2 + m_nOriginY);\r\n}\r\n\r\nvoid CGraphics::DrawLineDot(int x1, int y1, int x2, int y2)\r\n{\r\n\tBOOL r;\r\n\tHGDIOBJ old = ::SelectObject(m_hDc, m_hPenDot);\r\n\tr = ::MoveToEx(m_hDc, x1 + m_nOriginX, y1 + m_nOriginY, NULL);\r\n\tr = ::LineTo(m_hDc, x2 + m_nOriginX, y2 + m_nOriginY);\r\n}\r\n\r\nCFont::CFont(const char* pFaceName, int nHeight, FontWeight tWeight)\r\n{\r\n\tmemset(&m_oLogFont, 0, sizeof(m_oLogFont));\r\n\r\n\tstrcpy(m_oLogFont.lfFaceName, pFaceName);\r\n\tm_oLogFont.lfHeight = nHeight;\r\n\tSetWeight(tWeight);\r\n\tm_oLogFont.lfQuality = CLEARTYPE_QUALITY;\r\n}\r\n\r\nvoid CFont::SetFace(const char* pFaceName)\r\n{\r\n\tReleaseHandle();\r\n\tstrcpy(m_oLogFont.lfFaceName, pFaceName);\r\n}\r\n\r\nvoid CFont::SetHeight(int h)\r\n{\r\n\tReleaseHandle();\r\n\tm_oLogFont.lfHeight = h;\r\n}\r\n\r\nvoid CFont::SetWeight(FontWeight tWeight)\r\n{\r\n\tReleaseHandle();\r\n\tswitch(tWeight)\r\n\t{\r\n\t\tcase THIN:\r\n\t\t\tm_oLogFont.lfWeight = 100; break;\r\n\t\tcase NORMAL:\r\n\t\t\tm_oLogFont.lfWeight = 400; break;\r\n\t\tcase BOLD:\r\n\t\t\tm_oLogFont.lfWeight = 700; break;\r\n\t}\r\n}\r\n\r\nvoid CFont::SetItalic(BOOL bFlag)\r\n{\r\n\tReleaseHandle();\r\n\tm_oLogFont.lfItalic = bFlag;\r\n}\r\n\r\nvoid CFont::SetUnderline(BOOL bFlag)\r\n{\r\n\tReleaseHandle();\r\n\tm_oLogFont.lfUnderline = bFlag;\r\n}\r\n\r\nvoid CFont::SetStrikeOut(BOOL bFlag)\r\n{\r\n\tReleaseHandle();\r\n\tm_oLogFont.lfStrikeOut = bFlag;\r\n}\r\n\r\nHFONT CFont::GetFont()\r\n{\r\n\tif (NULL == m_hFont)\r\n\t\tm_hFont = CreateFontIndirect(&m_oLogFont);\r\n\r\n\treturn m_hFont;\r\n}\r\n\r\nvoid CFont::ReleaseHandle()\r\n{\r\n\tif (NULL != m_hFont)\r\n\t{\r\n\t\tDeleteObject(m_hFont);\r\n\t\tm_hFont = NULL;\r\n\t}\r\n}\r\n\r\n\r\n"
  },
  {
    "path": "src/Graphics.h",
    "content": "#pragma once\r\n\r\n#include <windows.h>\r\n\r\nclass CFont;\r\n\r\ntypedef struct tagSTYLE\r\n{\r\n\tint\t\tnColor;\r\n\tint\t\tnBgColor;\r\n\tint\t\tnTextFormat;\t// win32 DrawText macro: DT_...\r\n\tCFont*\tpFont;\r\n}STYLE;\r\n\r\nclass CGraphics\r\n{\r\npublic:\r\n\tCGraphics(HWND hWnd);\r\n\tCGraphics(HDC hParentDc, int w, int h);\r\n\t~CGraphics(void);\r\n\r\n\t//void SetErase() { m_bNeedErase = TRUE; };\r\n\tvoid BeginPaint();\r\n\tvoid EndPaint();\r\n\tconst RECT* GetPaintRect();\r\n\r\n\tvoid SetOrigin(int x, int y);\r\n\tvoid DrawRoundRect(const RECT* pRect, int nEllipseWidth, int nEllipseHeight);\r\n\tvoid DrawText(const RECT* pRect, char* pText, int nFormat, BOOL bTransparent = TRUE);\r\n\tvoid SetColor(int rgb);\r\n\tvoid SetBgColor(int rgb);\r\n\tvoid SetFont(CFont* pFont);\r\n\tvoid Copy(const RECT* pDestRect, CGraphics* pSrc, int x, int y);\r\n\tvoid DrawRect(const RECT* pRect);\r\n\tvoid DrawLine(int x1, int y1, int x2, int y2);\r\n\tvoid DrawLineDot(int x1, int y1, int x2, int y2);\r\n\tvoid DrawEllipse(const RECT* pRect);\r\n\r\nprivate:\r\n\tHWND\t\t\tm_hWnd;\r\n\tHDC\t\t\t\tm_hWndDc;\r\n\tHDC\t\t\t\tm_hDc;\r\n\tPAINTSTRUCT\t\tm_ps;\r\n\tHBITMAP\t\t\tm_hBgBm;\r\n\r\n\tint\t\t\t\tm_nOriginX;\r\n\tint\t\t\t\tm_nOriginY;\r\n\r\n\tint\t\t\t\tm_nColor;\r\n\tint\t\t\t\tm_nBgColor;\r\n\r\n\tHBRUSH\t\t\tm_hBrush;\r\n\tHPEN\t\t\tm_hPen;\r\n\tHPEN\t\t\tm_hPenDot;\r\n\r\n\t//BOOL\t\t\tm_bNeedErase;\r\n\tRECT\t\t\tm_oSize;\r\n};\r\n\r\nclass CFont\r\n{\r\npublic:\r\n\ttypedef enum { THIN, NORMAL, BOLD } FontWeight;\r\n\r\n\tCFont(const char* pFaceName, int nSize, FontWeight tWeight);\r\n\t~CFont() { ReleaseHandle(); };\r\n\r\n\tvoid SetFace(const char* pFaceName);\r\n\tvoid SetHeight(int nSize);\r\n\tvoid SetWeight(FontWeight tWeight);\r\n\tvoid SetItalic(BOOL bFlag);\r\n\tvoid SetUnderline(BOOL bFlag);\r\n\tvoid SetStrikeOut(BOOL bFlag);\r\n\r\n\tHFONT\tGetFont();\r\n\r\nprivate:\r\n\tvoid ReleaseHandle();\r\n\r\n\tLOGFONT\t\tm_oLogFont;\r\n\tHFONT\t\tm_hFont;\r\n};\r\n\r\n"
  },
  {
    "path": "src/LaButton.cpp",
    "content": "#include \"StdAfx.h\"\r\n#include \"LaButton.h\"\r\n\r\nCLaButton::CLaButton(IPaintableParent* pParent, const char* pText, const RECT* pRect, ButtonStyle nStyle/* = BT_NORMAL */, CFont* pFont/* = NULL */)\r\n{\r\n\tInitButton(pParent, pText, pRect, nStyle, pFont);\r\n}\r\n\r\nvoid CLaButton::InitButton(IPaintableParent* pParent, const char* pText, const RECT* pRect, ButtonStyle nStyle, CFont* pFont)\r\n{\r\n\tm_nIdxTxt = 0;\r\n\tm_pParent = pParent;\r\n\tm_oRect = *pRect;\r\n\tm_nStyle = nStyle;\r\n\tm_pFont = pFont;\r\n\r\n\tm_nState = BS_UP;\r\n\tm_bIsDown = FALSE;\r\n\tm_bMouseOver = FALSE;\r\n\tm_bMouseHold = FALSE;\r\n\r\n\tm_pKeyboardEventListener = NULL;\r\n\tm_pMouseMoveEventListener = NULL;\r\n\tm_pMouseKeyEventListener = NULL;\r\n\r\n\tm_nWantKeyCode = 0;\r\n\r\n\tResolveTextList(pText);\r\n}\r\n\r\nCLaButton::~CLaButton(void)\r\n{\r\n\twhile (0 < m_vText.size())\r\n\t{\r\n\t\tdelete[] m_vText[m_vText.size() - 1];\r\n\t\tm_vText.pop_back();\r\n\t}\r\n}\r\n\r\nvoid CLaButton::AddKeyboardEventListener(IKeyboardEventListener* pListener)\r\n{\r\n\tm_pKeyboardEventListener = pListener;\r\n}\r\n\r\nvoid CLaButton::AddMouseMoveEventListener(IMouseMoveEventListener* pListener)\r\n{\r\n\tm_pMouseMoveEventListener = pListener;\r\n}\r\n\r\nvoid CLaButton::AddMouseKeyEventListener(IMouseKeyEventListener* pListener)\r\n{\r\n\tm_pMouseKeyEventListener = pListener;\r\n}\r\n\r\nBOOL CLaButton::IsRelated(int x, int y)\r\n{\r\n\tRECT rect = m_oRect;\r\n\tBOOL r = IControl::PointInRect(&rect, x, y);\r\n\tif (r != m_bMouseOver)\r\n\t{\r\n\t\tm_bMouseOver = r;\r\n\t\tm_pParent->Invalidate(&rect);\r\n\t}\r\n\r\n\treturn m_bMouseHold || r;\r\n}\r\n\r\nvoid CLaButton::GetRect(RECT* r)\r\n{\r\n\t*r = m_oRect;\r\n}\r\n\r\nvoid CLaButton::SetRect(const RECT* r)\r\n{\r\n\tm_oRect = *r;\r\n\tm_pParent->Invalidate(r);\r\n}\r\n\r\nvoid CLaButton::SetText(const char* pNewText)\r\n{\r\n\twhile (0 < m_vText.size())\r\n\t{\r\n\t\tdelete[] m_vText[m_vText.size() - 1];\r\n\t\tm_vText.pop_back();\r\n\t}\r\n\r\n\tResolveTextList(pNewText);\r\n\tm_pParent->Invalidate(&m_oRect);\r\n}\r\n\r\nBOOL CLaButton::OnPaint(void* owner, CGraphics* g, const RECT* pRect)\r\n{\r\n\tRECT r = m_oRect;\r\n\tOffsetRect(&r, -r.left, -r.top);\r\n\t\r\n\tif (BS_UP == m_nState)\r\n\t{\r\n\t\tg->SetBgColor(RGB(255, 255, 255));\r\n\r\n\t\tif (m_bMouseOver)\r\n\t\t{\r\n\t\t\tg->SetColor(RGB(0, 0, 0));\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tg->SetColor(RGB(127, 127, 127));\r\n\t\t}\r\n\t}\r\n\telse\r\n\t{\r\n\t\tg->SetColor(RGB(0, 0, 0));\r\n\t\tg->SetBgColor(RGB(240, 240, 240));\r\n\t}\r\n\r\n\tint rw = (r.right - r.left) / 2;\r\n\tint rh = (r.bottom - r.top) / 2;\r\n\tif (rw > 16) rw = 16;\r\n\tif (rh > 16) rh = 16;\r\n\tint rd = (rw > rh ? rh : rw);\r\n\r\n\tg->DrawRoundRect(&r, rd, rd);\r\n\r\n\tif (m_pFont)\r\n\t\tg->SetFont(m_pFont);\r\n\r\n\tg->DrawText(&r, m_vText[m_nIdxTxt], DT_VCENTER|DT_CENTER|DT_SINGLELINE);\r\n\r\n\treturn TRUE;\r\n}\r\n\r\nvoid CLaButton::ResolveTextList(const char* pText)\r\n{\r\n\tm_nCntTxt = 0;\r\n\tfor (int i = 0, j; '\\0' != pText[i]; i = j, ++m_nCntTxt)\r\n\t{\r\n\t\tfor (j = i; '\\0' != pText[j] && ',' != pText[j]; ++j)\r\n\t\t{\r\n\t\t}\r\n\r\n\t\tm_vText.push_back(new char[j - i + 1]);\r\n\t\tstrncpy(m_vText[m_nCntTxt], pText + i, j - i);\r\n\t\tm_vText[m_nCntTxt][j - i] = '\\0';\r\n\r\n\t\tif (',' == pText[j])\r\n\t\t\t++j;\r\n\t}\r\n\r\n\tm_nIdxTxt = 0;\r\n}\r\n\r\nBOOL CLaButton::OnKeyDown(void* owner, int nKeyCode)\r\n{\r\n\tif (m_nWantKeyCode == nKeyCode)\r\n\t{\r\n\t\tm_nState = BS_DOWN;\r\n\r\n\t\tm_pParent->Invalidate(&m_oRect);\r\n\r\n\t\tif (m_pKeyboardEventListener)\r\n\t\t\tm_pKeyboardEventListener->OnKeyDown(this, nKeyCode);\r\n\r\n\t\treturn TRUE;\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nBOOL CLaButton::OnKeyUp(void* owner, int nKeyCode)\r\n{\r\n\tif (m_nWantKeyCode == nKeyCode)\r\n\t{\r\n\t\tif (BT_LOCKABLE == m_nStyle)\r\n\t\t{\r\n\t\t\tm_bIsDown = !m_bIsDown;\r\n\t\t\tm_nState = (m_bIsDown ? BS_DOWN : BS_UP);\r\n\t\t}\r\n\t\telse\r\n\t\t\tm_nState = BS_UP;\r\n\r\n\t\tm_pParent->Invalidate(&m_oRect);\r\n\r\n\t\tif (m_pKeyboardEventListener)\r\n\t\t\tm_pKeyboardEventListener->OnKeyUp(this, nKeyCode);\r\n\r\n\t\tOnClick(this);\r\n\r\n\t\treturn TRUE;\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nBOOL CLaButton::OnMouseMove(void* owner, int x, int y)\r\n{\r\n\tif (m_pMouseMoveEventListener)\r\n\t{\r\n\t\treturn m_pMouseMoveEventListener->OnMouseMove(this, x, y);\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nBOOL CLaButton::OnMouseKeyDown(void* owner, MouseKeyType nMkt, int x, int y)\r\n{\r\n\tm_bMouseHold = TRUE;\r\n\tm_nState = BS_DOWN;\r\n\tm_pParent->Invalidate(&m_oRect);\r\n\r\n\tif (m_pMouseKeyEventListener)\r\n\t\tm_pMouseKeyEventListener->OnMouseKeyDown(this, nMkt, x, y);\r\n\r\n\treturn TRUE;\r\n}\r\n\r\nBOOL CLaButton::OnMouseKeyUp(void* owner, MouseKeyType nMkt, int x, int y)\r\n{\r\n\tm_bMouseHold = FALSE;\r\n\tif (BT_LOCKABLE == m_nStyle)\r\n\t{\r\n\t\tm_bIsDown = !m_bIsDown;\r\n\t\tm_nState = (m_bIsDown ? BS_DOWN : BS_UP);\r\n\t}\r\n\telse\r\n\t\tm_nState = BS_UP;\r\n\r\n\tif (m_nCntTxt == ++m_nIdxTxt)\r\n\t\tm_nIdxTxt = 0;\r\n\r\n\tm_pParent->Invalidate(&m_oRect);\r\n\r\n\tif (m_pMouseKeyEventListener)\r\n\t\tm_pMouseKeyEventListener->OnMouseKeyUp(this, nMkt, x, y);\r\n\r\n\tif (IControl::PointInRect(&m_oRect, x + m_oRect.left, y + m_oRect.top))\r\n\t\tOnClick(this);\r\n\r\n\treturn TRUE;\r\n}\r\n\r\nBOOL CLaButton::OnClick(void* owner)\r\n{\r\n\tBOOL bProcess = FALSE;\r\n\tif (m_pKeyboardEventListener)\r\n\t\tbProcess = m_pKeyboardEventListener->OnClick(this);\r\n\r\n\tif (m_pMouseKeyEventListener && !bProcess)\r\n\t\tbProcess = m_pMouseKeyEventListener->OnClick(this);\r\n\r\n\treturn bProcess;\r\n}\r\n\r\n"
  },
  {
    "path": "src/LaButton.h",
    "content": "#pragma once\r\n\r\n#include \"EventManagerWin32.h\"\r\n\r\nclass CLaButton \r\n\t: public IPaintEventControl\r\n\t, public IMouseMoveEventControl\r\n\t, public IMouseKeyEventControl\r\n\t, public IKeyboardEventControl\r\n\t, public IUserData\r\n{\r\npublic:\r\n\ttypedef enum { BS_UP, BS_DOWN } ButtonState;\r\n\ttypedef enum { BT_NORMAL, BT_LOCKABLE } ButtonStyle;\r\n\r\npublic:\r\n\tCLaButton(IPaintableParent* pParent, const char* pText, const RECT* pRect, ButtonStyle nStyle = BT_NORMAL, CFont* pFont = NULL);\r\n\tvirtual ~CLaButton(void);\r\n\r\n\tvirtual BOOL IsRelated(int x, int y);\r\n\tvirtual void GetRect(RECT* pRect);\r\n\tvirtual BOOL OnPaint(void* owner, CGraphics* g, const RECT* pRect);\r\n\tvirtual BOOL OnKeyDown(void* owner, int nKeyCode);\r\n\tvirtual BOOL OnKeyUp(void* owner, int nKeyCode);\r\n\tvirtual BOOL OnMouseMove(void* owner, int x, int y);\r\n\tvirtual BOOL OnMouseKeyDown(void* owner, MouseKeyType nMkt, int x, int y);\r\n\tvirtual BOOL OnMouseKeyUp(void* owner, MouseKeyType nMkt, int x, int y);\r\n\tvirtual BOOL OnClick(void* owner);\r\n\r\n\tvirtual void SetRect(const RECT* pRect);\r\n\tvirtual void SetText(const char* pNewText);\r\n\r\n\tvirtual void SetUserData(void* pUserData) { m_pUserData = pUserData; };\r\n\tvirtual void* GetUserData() { return m_pUserData; };\r\n\r\n\tvirtual BOOL IsPressed() { return m_bIsDown; };\r\n\r\n\tvoid AddKeyboardEventListener(IKeyboardEventListener* pListener);\r\n\tvoid AddMouseMoveEventListener(IMouseMoveEventListener* pListener);\r\n\tvoid AddMouseKeyEventListener(IMouseKeyEventListener* pListener);\r\n\r\n\tvoid SetWantKeyCode(int nKeyCode) { m_nWantKeyCode = nKeyCode; };\r\n\tint GetWantKeyCode() { return m_nWantKeyCode; };\r\n\r\nprivate:\r\n\tIPaintableParent*\t\tm_pParent;\r\n\tCFont*\t\tm_pFont;\r\n\tvector<char *>\t\tm_vText;\r\n\tRECT\tm_oRect;\r\n\tButtonStyle\t\tm_nStyle;\r\n\tButtonState\t\tm_nState;\r\n\tBOOL\tm_bMouseOver;\r\n\tint\t\tm_nWantKeyCode;\r\n\tBOOL\tm_bIsDown;\r\n\tBOOL\tm_bMouseHold;\r\n\tint\t\tm_nIdxTxt;\r\n\tint\t\tm_nCntTxt;\r\n\r\n\tIKeyboardEventListener*\t\tm_pKeyboardEventListener;\r\n\tIMouseMoveEventListener*\tm_pMouseMoveEventListener;\r\n\tIMouseKeyEventListener*\t\tm_pMouseKeyEventListener;\r\n\r\n\tvoid*\tm_pUserData;\r\n\r\n\tvoid InitButton(IPaintableParent* pParent, const char* pText, const RECT* pRect, ButtonStyle nStyle, CFont* pFont);\r\n\tvoid ResolveTextList(const char* pText);\r\n};\r\n"
  },
  {
    "path": "src/LaHwControl.cpp",
    "content": "#include \"StdAfx.h\"\r\n\r\n#include \"LaHwControl.h\"\r\n//#include \"WinIo.h\"\r\n\r\nCLaHwControl::CLaHwControl(WORD nInitAddr, BYTE bInit)\r\n{\r\n\t//m_bInitOk = InitializeWinIo();\r\n\tif (m_bInitOk)\r\n\t{\r\n\t//\tm_bInitOk = SetPortVal(nInitAddr, bInit, 1);\r\n\t}\r\n}\r\n\r\nCLaHwControl::~CLaHwControl()\r\n{\r\n\t//if (m_bInitOk)\r\n\t//\tShutdownWinIo();\r\n}\r\n\r\nBOOL CLaHwControl::OutByte(WORD nAddr, BYTE b)\r\n{\r\n\tif (m_bInitOk && m_bState)\r\n\t{\r\n\t//\treturn SetPortVal(nAddr, b, 1);\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nBOOL CLaHwControl::GetState()\r\n{\r\n\treturn m_bState;\r\n}\r\n\r\nvoid CLaHwControl::SetState(BOOL bState)\r\n{\r\n\tm_bState = bState;\r\n}\r\n\r\n"
  },
  {
    "path": "src/LaHwControl.h",
    "content": "#pragma once\r\n\r\nclass CLaHwControl\r\n{\r\npublic:\r\n\tCLaHwControl(WORD nInitAddr, BYTE bInit);\r\n\t~CLaHwControl();\r\n\r\n\tBOOL OutByte(WORD nAddr, BYTE b);\r\n\tBOOL GetState();\r\n\tvoid SetState(BOOL bState);\r\n\r\nprivate:\r\n\tBOOL m_bInitOk;\r\n\tBOOL m_bState;\r\n};\r\n"
  },
  {
    "path": "src/LaJournalPanel.cpp",
    "content": "#include \"StdAfx.h\"\r\n#include \"lajournalpanel.h\"\r\n\r\nCLaJournalPanel::CLaJournalPanel(IPaintableParent* pParent, const RECT* pRect, const MORSECODE* pMorseList\r\n\t, int nMaxShortCount, STYLE* pStyle, IParseEventListener* pParseLsnr)\r\n{\r\n\tm_pParent = pParent;\r\n\tm_pParseLsnr = pParseLsnr;\r\n\tm_oRect = *pRect;\r\n\tm_pStyle = pStyle;\r\n\tm_pPaintBoard = pParent->NewGraphics(pRect->right - pRect->left, pRect->bottom - pRect->top);\r\n\tRECT r;\r\n\tSetRect(&r, 0, 0, pRect->right - pRect->left, pRect->bottom - pRect->top);\r\n\tm_pPaintBoard->DrawRect(&r);\r\n\t//m_pPaintBoard->DrawLine(0, pRect->bottom - pRect->top - 1, pRect->right - pRect->left, pRect->bottom - pRect->top - 1);\r\n\tm_nCurrPos = 0;\r\n\tm_pMorseParser = new CMorseParser(pMorseList, MORSECODECOUNT, nMaxShortCount, this);\r\n\tSetMaxShortCount(nMaxShortCount);\r\n\tm_nJitter = 0;\r\n\tm_nStateCount = 0;\r\n\tm_nStep = 1;\r\n}\r\n\r\nCLaJournalPanel::~CLaJournalPanel(void)\r\n{\r\n\tdelete m_pMorseParser;\r\n\tdelete m_pPaintBoard;\r\n}\r\n\r\nBOOL CLaJournalPanel::IsRelated(int x, int y)\r\n{\r\n\treturn IControl::PointInRect(&m_oRect, x, y);\r\n}\r\n\r\nvoid CLaJournalPanel::GetRect(RECT* r)\r\n{\r\n\t*r = m_oRect;\r\n}\r\n\r\nBOOL CLaJournalPanel::OnPaint(void* owner, CGraphics* g, const RECT* pRect)\r\n{\r\n\tint w = m_oRect.right - m_oRect.left;\r\n\tint h = m_oRect.bottom - m_oRect.top;\r\n\r\n\tRECT r;\r\n\tr.top = 0; r.bottom = h;\r\n\r\n\tr.left = 0; r.right = w - m_nCurrPos;\r\n\tg->Copy(&r, m_pPaintBoard, m_nCurrPos, 0);\r\n\r\n\tif (0 < m_nCurrPos)\r\n\t{\r\n\t\tr.left = w - m_nCurrPos; r.right = w;\r\n\t\tg->Copy(&r, m_pPaintBoard, 0, 0);\r\n\t}\r\n\r\n\treturn TRUE;\r\n}\r\n\r\nvoid CLaJournalPanel::Sample(int nState)\r\n{\r\n\t// sample filter\r\n\tswitch(m_nStep)\r\n\t{\r\n\t\tcase 1:\t// init\r\n\t\t{\r\n\t\t\tif (3 > m_nSampleDiv)\r\n\t\t\t{\r\n\t\t\t}\r\n\t\t\telse if (nState)\t// key down\r\n\t\t\t{\r\n\t\t\t\tm_nStateCount = 1;\r\n\t\t\t\tm_nStep = 2;\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tif (m_nSampleDiv <= ++m_nStateCount)\r\n\t\t\t{\r\n\t\t\t\tSampleRender(nState);\r\n\t\t\t\tm_pMorseParser->Sample(nState);\r\n\t\t\t\tm_nStateCount = 0;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase 2:\t// jitter(L) test\r\n\t\t{\r\n\t\t\t++m_nStateCount;\r\n\r\n\t\t\tif (!nState)\r\n\t\t\t{\r\n\t\t\t\tm_nStep = 3;\r\n\t\t\t}\r\n\t\t\telse if (m_nSampleDiv <= m_nStateCount)\r\n\t\t\t{\r\n\t\t\t\tSampleRender(nState);\r\n\t\t\t\tm_pMorseParser->Sample(nState);\r\n\t\t\t\tm_nStep = 1;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tcase 3: // jitter(H) test\r\n\t\t{\r\n\t\t\tif (nState)\r\n\t\t\t{\r\n\t\t\t\tif (m_nSampleDiv <= ++m_nStateCount)\r\n\t\t\t\t{\r\n\t\t\t\t\tSampleRender(nState);\r\n\t\t\t\t\tm_pMorseParser->Sample(nState);\r\n\t\t\t\t\tm_nStateCount = 0;\r\n\t\t\t\t\tm_nStep = 1;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t\tm_nStep = 2;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tm_nStateCount = 2;\r\n\t\t\t\tm_nStep = 1;\t// key up\r\n\t\t\t}\r\n\r\n\t\t\treturn;\r\n\t\t}\r\n\t}\r\n\r\n\tm_pParent->Invalidate(&m_oRect);\r\n}\r\n\r\nvoid CLaJournalPanel::SampleRender(int nState)\r\n{\r\n\tif (nState)\r\n\t\tm_pPaintBoard->SetColor(m_pStyle->nColor);\r\n\telse\r\n\t\tm_pPaintBoard->SetColor(m_pStyle->nBgColor);\r\n\r\n\tint y = 2;\r\n\r\n\tm_pPaintBoard->DrawLine(m_nCurrPos, y, m_nCurrPos, y + 5);\r\n\r\n\tm_pPaintBoard->SetColor(m_pStyle->nBgColor);\r\n\tm_pPaintBoard->DrawLine(m_nCurrPos, m_oRect.bottom - m_oRect.top - 16, m_nCurrPos, m_oRect.bottom - m_oRect.top - 1);\r\n\r\n\tif (++m_nCurrPos >= m_oRect.right - m_oRect.left)\r\n\t\tm_nCurrPos = 0;\r\n}\r\n\r\nvoid CLaJournalPanel::OnWorkOut(void* owner, const MORSECODE* pResult)\r\n{\r\n\tchar buff[] = { '#', '\\0' };\r\n\r\n\tif (pResult)\r\n\t\tbuff[0] = pResult->nAscCode;\r\n\r\n\tm_pPaintBoard->SetColor(m_pStyle->nColor);\r\n\tm_pPaintBoard->SetFont(m_pStyle->pFont);\r\n\r\n\tRECT r;\r\n\tr.right = m_nCurrPos;\r\n\tr.left = r.right - 12;\r\n\tr.bottom = m_oRect.bottom - m_oRect.top;\r\n\tr.top = r.bottom - 16;\r\n\tm_pPaintBoard->DrawText(&r, buff, DT_VCENTER|DT_CENTER|DT_SINGLELINE);\r\n\r\n\tif (r.left < 0)\r\n\t{\r\n\t\tint w = m_oRect.right - m_oRect.left;\r\n\t\tr.right += w;\r\n\t\tr.left += w;\r\n\t\tm_pPaintBoard->DrawText(&r, buff, DT_VCENTER|DT_CENTER|DT_SINGLELINE);\r\n\t}\r\n\r\n\tif (m_pParseLsnr)\r\n\t\tm_pParseLsnr->OnWorkOut(this, pResult);\r\n}\r\n\r\nvoid CLaJournalPanel::SetMaxShortCount(int nCount)\r\n{\r\n\tm_nSampleDiv = nCount / 3;\r\n\tif (0 == m_nSampleDiv)\r\n\t\tm_nSampleDiv = 1;\r\n\r\n\tm_pMorseParser->SetMaxShortCount(nCount / m_nSampleDiv);\r\n}\r\n"
  },
  {
    "path": "src/LaJournalPanel.h",
    "content": "#pragma once\r\n\r\n#include \"EventManagerWin32.h\"\r\n#include \"MorseParser.h\"\r\n\r\nclass CLaJournalPanel\r\n\t: public IPaintEventControl\r\n\t, public IParseEventListener\r\n{\r\npublic:\r\n\tCLaJournalPanel(IPaintableParent* pParent, const RECT* pRect, const MORSECODE* pMorseList, int nMaxShortCount, STYLE* pStyle, IParseEventListener* pParseLsnr);\r\n\tvirtual ~CLaJournalPanel(void);\r\n\r\n\tvirtual BOOL IsRelated(int x, int y);\r\n\tvirtual void GetRect(RECT* r);\r\n\tvirtual BOOL OnPaint(void* owner, CGraphics* g, const RECT* pRect);\r\n\tvirtual void OnWorkOut(void* owner, const MORSECODE* pResult);\r\n\r\n\tvirtual void Sample(int nState);\r\n\tvoid SetMaxShortCount(int nCount);\r\n\r\nprivate:\r\n\tIPaintableParent*\t\tm_pParent;\r\n\tIParseEventListener*\tm_pParseLsnr;\r\n\tSTYLE*\t\tm_pStyle;\r\n\tRECT\tm_oRect;\r\n\tCGraphics*\tm_pPaintBoard;\r\n\tint\t\tm_nCurrPos;\r\n\tint\t\tm_nSampleDiv;\r\n\tint\t\tm_nJitter;\r\n\tint\t\tm_nStateCount;\r\n\tint\t\tm_nStep;\r\n\r\n\tCMorseParser*\tm_pMorseParser;\r\n\r\n\tvoid SampleRender(int nState);\r\n};\r\n"
  },
  {
    "path": "src/LaLabel.cpp",
    "content": "#include \"StdAfx.h\"\r\n#include \"LaLabel.h\"\r\n\r\n#include <assert.h>\r\n\r\nCLaLabel::CLaLabel(IPaintableParent* pParent, const RECT* pRect, const char* pText, STYLE* pStyle, const char* pMutexName/* = NULL */)\r\n{\r\n\tm_pParent = pParent;\r\n\tm_oRect = *pRect;\r\n\tm_pStyle = pStyle;\r\n\r\n\tif (pText)\r\n\t{\r\n\t\tstrncpy(m_vText, pText, MAX_LABEL_TEXT_LEN);\r\n\t\tm_vText[MAX_LABEL_TEXT_LEN] = '\\0';\r\n\t}\r\n\telse\r\n\t\tm_vText[0] = '\\0';\r\n\r\n\tm_hMutex = (pMutexName ? CreateMutex(NULL, FALSE, pMutexName) : NULL);\r\n}\r\n\r\nCLaLabel::~CLaLabel(void)\r\n{\r\n}\r\n\r\nBOOL CLaLabel::IsRelated(int x, int y)\r\n{\r\n\treturn IControl::PointInRect(&m_oRect, x, y);\r\n}\r\n\r\nvoid CLaLabel::GetRect(RECT* r)\r\n{\r\n\t*r = m_oRect;\r\n}\r\n\r\nBOOL CLaLabel::OnPaint(void* owner, CGraphics* g, const RECT* pRect)\r\n{\r\n\tRECT r = m_oRect;\r\n\tOffsetRect(&r, -r.left, -r.top);\r\n\tg->SetBgColor(m_pStyle->nBgColor);\r\n\tg->DrawRect(&r);\r\n\tg->SetFont(m_pStyle->pFont);\r\n\tg->SetColor(m_pStyle->nColor);\r\n\tg->DrawText(&r, m_vText, m_pStyle->nTextFormat);\r\n\r\n\treturn TRUE;\r\n}\r\n\r\nvoid CLaLabel::SetText(const char* pText)\r\n{\r\n\tif (pText)\r\n\t{\r\n\t\tstrncpy(m_vText, pText, MAX_LABEL_TEXT_LEN);\r\n\t\tm_vText[MAX_LABEL_TEXT_LEN] = '\\0';\r\n\t}\r\n\telse\r\n\t\tm_vText[0] = '\\0';\r\n\r\n\tm_pParent->Invalidate(&m_oRect);\r\n}\r\n\r\nvoid CLaLabel::GetText(char* pText, int nSize)\r\n{\r\n\tstrncpy(pText, m_vText, nSize);\r\n}\r\n\r\nconst char* CLaLabel::GetText()\r\n{\r\n\treturn (const char *)m_vText;\r\n}\r\n\r\nBOOL CLaLabel::PushChar(char ch)\r\n{\r\n\tassert(m_hMutex);\r\n\tBOOL r = FALSE;\r\n\r\n\tif (WAIT_OBJECT_0 == WaitForSingleObject(m_hMutex, 1000L))\r\n\t{\r\n\t\tfor (int i = 0; i < MAX_LABEL_TEXT_LEN; ++i)\r\n\t\t{\r\n\t\t\tif (!m_vText[i])\r\n\t\t\t{\r\n\t\t\t\tm_vText[i] = ch;\r\n\t\t\t\tm_vText[i + 1] = '\\0';\r\n\t\t\t\tr = TRUE;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t\tReleaseMutex(m_hMutex);\r\n\t\tm_pParent->Invalidate(&m_oRect);\r\n\t}\r\n\r\n\treturn r;\r\n}\r\n\r\nchar CLaLabel::PopChar()\r\n{\r\n\tassert(m_hMutex);\r\n\r\n\tchar r = '\\0';\r\n\tif (WAIT_OBJECT_0 == WaitForSingleObject(m_hMutex, 1000L))\r\n\t{\r\n\t\tr = m_vText[0];\r\n\t\tfor (int i = 0; i < MAX_LABEL_TEXT_LEN; ++i)\r\n\t\t{\r\n\t\t\tif (m_vText[i])\r\n\t\t\t\tm_vText[i] = m_vText[i + 1];\r\n\t\t\telse\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tReleaseMutex(m_hMutex);\r\n\t\tm_pParent->Invalidate(&m_oRect);\r\n\t}\r\n\r\n\treturn r;\r\n}\r\n"
  },
  {
    "path": "src/LaLabel.h",
    "content": "#pragma once\r\n\r\n#include \"EventManagerWin32.h\"\r\n\r\n#define MAX_LABEL_TEXT_LEN\t\t8193\r\n\r\nclass CLaLabel\r\n\t: public IPaintEventControl\r\n{\r\npublic:\r\n\tCLaLabel(IPaintableParent* pParent, const RECT* pRect, const char* pText, STYLE* pStyle, const char* pMutexName = NULL);\r\n\tvirtual ~CLaLabel(void);\r\n\r\n\tvirtual BOOL IsRelated(int x, int y);\r\n\tvirtual void GetRect(RECT* r);\r\n\tvirtual BOOL OnPaint(void* owner, CGraphics* g, const RECT* pRect);\r\n\r\n\tvirtual void SetText(const char* pText);\r\n\tvirtual void GetText(char* pText, int nSize);\r\n\tvirtual const char* GetText();\r\n\r\n\tvirtual BOOL PushChar(char ch);\r\n\tvirtual char PopChar();\r\n\r\nprivate:\r\n\tIPaintableParent*\t\tm_pParent;\r\n\tSTYLE*\t\tm_pStyle;\r\n\tRECT\t\tm_oRect;\r\n\r\n\tchar\t\tm_vText[MAX_LABEL_TEXT_LEN + 1];\r\n\r\n\tHANDLE\t\tm_hMutex;\r\n};\r\n"
  },
  {
    "path": "src/LaLine.cpp",
    "content": "#include \"StdAfx.h\"\r\n#include \"LaLine.h\"\r\n\r\nCLaLine::CLaLine(IPaintableParent* pParent, int x1, int y1, int x2, int y2)\r\n{\r\n\tm_pParent = pParent;\r\n\r\n\tm_x1 = x1;\r\n\tm_x2 = x2;\r\n\tm_y1 = y1;\r\n\tm_y2 = y2;\r\n\r\n\tif (x1 > x2) x1 ^= x2 ^= x1 ^= x2;\r\n\tif (y1 > y2) y1 ^= y2 ^= y1 ^= y2;\r\n\r\n\tm_oRect.left = x1;\r\n\tm_oRect.top = y1;\r\n\tm_oRect.right = x2 + 1;\r\n\tm_oRect.bottom = y2 + 1;\r\n\r\n\tm_x1 -= m_oRect.left;\r\n\tm_x2 -= m_oRect.left;\r\n\tm_y1 -= m_oRect.top;\r\n\tm_y2 -= m_oRect.top;\r\n}\r\n\r\nCLaLine::~CLaLine()\r\n{\r\n}\r\n\r\nBOOL CLaLine::IsRelated(int x, int y)\r\n{\r\n\treturn IControl::PointInRect(&m_oRect, x, y);\r\n}\r\n\r\nvoid CLaLine::GetRect(RECT* r)\r\n{\r\n\t*r = m_oRect;\r\n}\r\n\r\nBOOL CLaLine::OnPaint(void* owner, CGraphics* g, const RECT* pRect)\r\n{\r\n\tg->SetColor(0);\r\n\tg->DrawLine(m_x1, m_y1, m_x2, m_y2);\r\n\r\n\treturn TRUE;\r\n}\r\n"
  },
  {
    "path": "src/LaLine.h",
    "content": "#pragma once\r\n\r\n#include \"EventManagerWin32.h\"\r\n\r\nclass CLaLine\r\n\t: public IPaintEventControl\r\n{\r\npublic:\r\n\tCLaLine(IPaintableParent* pParent, int x1, int y1, int x2, int y2);\r\n\tvirtual ~CLaLine();\r\n\r\n\tvirtual BOOL IsRelated(int x, int y);\r\n\tvirtual void GetRect(RECT* r);\r\n\tvirtual BOOL OnPaint(void* owner, CGraphics* g, const RECT* pRect);\r\n\r\nprivate:\r\n\tIPaintableParent*\t\tm_pParent;\r\n\tRECT\tm_oRect;\r\n\tint m_x1;\r\n\tint m_x2;\r\n\tint m_y1;\r\n\tint m_y2;\r\n\r\n};\r\n"
  },
  {
    "path": "src/LaNetwork.cpp",
    "content": "#include \"StdAfx.h\"\r\n//#include \"winsock2.h\"\r\n//#include \"Ws2tcpip.h\"\r\n#include \"LaNetwork.h\"\r\n\r\n#define JOIN_SAFELY(ht)\t\t\t\t\t\t\t\t\\\r\n{\t\t\t\t\t\t\t\t\t\t\t\t\t\\\r\n\tif (NULL != ht)\t\t\t\t\t\t\t\t\t\\\r\n\t{\t\t\t\t\t\t\t\t\t\t\t\t\\\r\n\t\tDWORD nExitCode_j = -1;\t\t\t\t\t\t\\\r\n\t\tif (GetExitCodeThread(ht, &nExitCode_j))\t\\\r\n\t\t\tif (STILL_ACTIVE == nExitCode_j)\t\t\\\r\n\t\t\t\tWaitForSingleObject(ht, INFINITE);\t\\\r\n\t\tht = NULL;\t\t\t\t\t\t\t\t\t\\\r\n\t}\t\t\t\t\t\t\t\t\t\t\t\t\\\r\n}\r\n\r\nCLaNetwork::CLaNetwork(DWORD nFlgs)\r\n{\r\n\tm_nFlgs = nFlgs;\r\n\tm_bWsaInit = FALSE;\r\n\r\n\tm_pEventListener = NULL;\r\n\tm_pFrameListener = NULL;\r\n\r\n\tm_pStbTabHead = NULL;\r\n\tm_pDynTabHead = NULL;\r\n\r\n\tm_hNwRecvThread = m_hNwSendThread = NULL;\r\n\r\n\tm_nSendInPos = m_nSendOutPos = 0;\r\n\r\n\tm_socket = NULL;\r\n}\r\n\r\nCLaNetwork::~CLaNetwork()\r\n{\r\n\tif (m_hNwRecvThread)\r\n\t{\r\n\t\tShutdown();\r\n\t\tResumeThread(m_hNwRecvThread);\r\n\t\tJOIN_SAFELY(m_hNwRecvThread);\r\n\t}\r\n\r\n\tif (m_hNwSendThread)\r\n\t{\r\n\t\tShutdown();\r\n\t\tResumeThread(m_hNwSendThread);\r\n\t\tJOIN_SAFELY(m_hNwSendThread);\r\n\t}\r\n\r\n\tif (m_bWsaInit)\r\n\t{\r\n\t\tWSACleanup();\r\n\t\tm_bWsaInit = FALSE;\r\n\t}\r\n\r\n\twhile(m_pStbTabHead)\r\n\t{\r\n\t\tLANWSRCNODE* p = m_pStbTabHead->next;\r\n\t\tdelete m_pStbTabHead;\r\n\t\tm_pStbTabHead = p;\r\n\t}\r\n}\r\n\r\nBOOL CLaNetwork::AppendStbSrcNode(const LANWSRCNODE* pStbSrc)\r\n{\r\n\tLANWSRCNODE* p = m_pStbTabHead;\r\n\r\n\tif (!m_pStbTabHead)\r\n\t{\r\n\t\tm_pStbTabHead = new LANWSRCNODE;\r\n\t\tp = m_pStbTabHead;\r\n\t}\r\n\telse\r\n\t{\r\n\t\twhile(p->next)\r\n\t\t{\r\n\t\t\tif (p->base.nAddr == pStbSrc->base.nAddr && p->base.nPort == pStbSrc->base.nPort)\r\n\t\t\t\treturn FALSE;\r\n\r\n\t\t\tp = p->next;\r\n\t\t}\r\n\r\n\t\tp->next = new LANWSRCNODE;\r\n\t\tp = p->next;\r\n\t}\r\n\r\n\tp->base = pStbSrc->base;\r\n\tp->attr = pStbSrc->attr;\r\n\tp->branch = NULL;\r\n\tp->next = NULL;\r\n\r\n\treturn TRUE;\r\n}\r\n\r\nBOOL CLaNetwork::AppendNodeByAddr(const sockaddr* pAddr)\r\n{\r\n\tif (AF_INET == pAddr->sa_family)\r\n\t{\r\n\t\tLANWSRCNODE *pNode = new LANWSRCNODE;\r\n\t\tpNode->base.nAddr = ((sockaddr_in*)pAddr)->sin_addr.S_un.S_addr;\r\n\t\tpNode->base.nPort = ((sockaddr_in*)pAddr)->sin_port;\r\n\t\tpNode->branch = pNode->next = NULL;\r\n\r\n\t\treturn AppendStbSrcNode(pNode);\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nBOOL CLaNetwork::Startup(WORD nPort)\r\n{\r\n\tif (m_hNwRecvThread || m_hNwSendThread)\r\n\t\treturn TRUE; // only startup once, at the same time\r\n\r\n\tif (!m_bWsaInit)\r\n\t{\r\n\t\tWSADATA wsaData;\r\n\t\t// start up as need\r\n\t\tif (NO_ERROR != WSAStartup(MAKEWORD(2,2), &wsaData))\r\n\t\t\treturn FALSE;\r\n\r\n\t\tm_bWsaInit = TRUE;\r\n\t}\r\n\r\n\tm_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP/*IPPROTO_TCP*/);\r\n\tif (INVALID_SOCKET == m_socket)\r\n\t\treturn FALSE;\r\n\r\n\tif (!Bind(nPort))\r\n\t\treturn FALSE;\r\n\r\n\tm_bNeedExit = FALSE;\r\n\r\n\tm_hNwRecvThread = CreateThread(NULL, 0, NwRecvThreadProc, this, 0, &m_nNwRecvThreadID);\r\n\tif (m_hNwRecvThread)\r\n\t{\r\n\t\tm_hNwSendThread = CreateThread(NULL, 0, NwSendThreadProc, this, 0, &m_nNwSendThreadID);\r\n\t\tif (m_hNwSendThread)\r\n\t\t\treturn TRUE;\r\n\r\n\t\tShutdown();\r\n\t\tJOIN_SAFELY(m_hNwRecvThread);\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nBOOL CLaNetwork::AppendKeyFrame(const LANWPKGKEYFRAME* pFrame)\r\n{\r\n\tint nNextPos = m_nSendInPos + 1;\r\n\tif (SEND_QUEUE_SIZE == nNextPos)\r\n\t\tnNextPos = 0;\r\n\tif (nNextPos == m_nSendOutPos)\r\n\t\treturn FALSE;\r\n\r\n\tm_vSendQ[m_nSendInPos] = *pFrame;\r\n\tm_nSendInPos = nNextPos;\r\n\r\n\tResumeThread(m_hNwSendThread);\r\n\r\n\treturn TRUE;\r\n}\r\n\r\nBOOL CLaNetwork::PickKeyFrame(LANWPKGKEYFRAME* pFrame)\r\n{\r\n\tif (IsSendKeyFrameQueueEmpty())\r\n\t\treturn FALSE; //empty Q\r\n\r\n\t*pFrame = m_vSendQ[m_nSendOutPos];\r\n\tif (++m_nSendOutPos == SEND_QUEUE_SIZE)\r\n\t\tm_nSendOutPos = 0;\r\n\r\n\treturn TRUE;\r\n}\r\n\r\nvoid CLaNetwork::Shutdown()\r\n{\r\n\tm_bNeedExit = TRUE;\r\n\r\n\tif (m_socket)\r\n\t{\r\n\t\tclosesocket(m_socket);\r\n\t\tm_socket = NULL;\r\n\t}\r\n}\r\n\r\nBOOL CLaNetwork::Bind(WORD nPort)\r\n{\r\n\tm_nLocalPort = nPort;\r\n\tsockaddr_in service;\r\n\tservice.sin_family = AF_INET;\r\n\tservice.sin_addr.s_addr = INADDR_ANY; // inet_addr(\"127.0.0.1\");\r\n\tservice.sin_port = htons(m_nLocalPort);\r\n\r\n\tif (bind(m_socket, (SOCKADDR*)&service, sizeof(service)) == SOCKET_ERROR)\r\n\t{\r\n\t\tif (m_pEventListener)\r\n\t\t\tm_pEventListener->OnEvent(NM_BIND_FAILED);\r\n\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\treturn TRUE;\r\n}\r\n\r\n#define NOTEVALIFNEEDEXIT(expr)\tif (!owner->m_bNeedExit) expr\r\n\r\nDWORD WINAPI CLaNetwork::NwRecvThreadProc(LPVOID pOwner)\r\n{\r\n\tCLaNetwork* owner = (CLaNetwork *)pOwner;\r\n\r\n\tsockaddr\tsaddr;\r\n\tint nFromlen = sizeof(saddr);\r\n\tchar\tsPkgBuff[RECV_BUFF_BYTES];\r\n\tint\tnFramePos;\r\n\tint nReadLen;\r\n\t\r\n\tLANWPKGHEAD* pLnph;\r\n\tLANWPKGKEYFRAME* pLnpkf;\r\n//\tLANWPKGSRCFRAME* pLnpsf;\r\n//\tLANWPKGTXTFRAME* pLnptf;\r\n\r\n\twhile(!owner->m_bNeedExit)\r\n\t{\r\n\t\tnReadLen = recvfrom(owner->m_socket, sPkgBuff, sizeof(sPkgBuff), 0, &saddr, &nFromlen);\r\n\t\tif (SOCKET_ERROR != nReadLen && !owner->m_bNeedExit)\r\n\t\t{\r\n\t\t\tif (sizeof(LANWPKGHEAD) > nReadLen)\r\n\t\t\t\tcontinue;\t// invalid package size\r\n\r\n\t\t\tnFramePos = 0;\r\n\t\t\tpLnph = (LANWPKGHEAD *)(sPkgBuff + nFramePos);\r\n\t\t\tif (LA_FLAG != pLnph->nLaFlg)\r\n\t\t\t\tcontinue;\t// invalid package head flag\r\n\r\n\t\t\tif (LNPF_KEEPALIVE == pLnph->nPkgFlgs)\r\n\t\t\t{\r\n\t\t\t\tif (sizeof(LANWPKGHEAD) != nReadLen)\r\n\t\t\t\t\tcontinue;\t// invalid keep-alive package size\r\n\r\n\t\t\t\t// TODO: handle keep alive package\r\n\t\t\t\towner->AppendNodeByAddr(&saddr);\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\tif (LNPF_OFF_LINE == pLnph->nPkgFlgs)\r\n\t\t\t{\r\n\t\t\t\tif (sizeof(LANWPKGHEAD) != nReadLen)\r\n\t\t\t\t\tcontinue;\t// invalid off-line package size\r\n\r\n\t\t\t\t// TODO: handle off-line package\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\r\n\t\t\tnFramePos += sizeof(LANWPKGHEAD);\r\n\r\n\t\t\tif (LNPF_KEY_FRAME & pLnph->nPkgFlgs)\r\n\t\t\t{\r\n\t\t\t\tif (LNPF_SERVER_FRAME & pLnph->nPkgFlgs)\r\n\t\t\t\t\tcontinue;\t// server must not send key-frame\r\n\r\n\t\t\t\tif (nFramePos + sizeof(LANWPKGKEYFRAME) > (UINT)nReadLen)\r\n\t\t\t\t\tcontinue;\t// package too small\r\n\r\n\t\t\t\tpLnpkf = (LANWPKGKEYFRAME *)(sPkgBuff + nFramePos);\r\n\r\n\t\t\t\tif (owner->m_pFrameListener)\r\n\t\t\t\t\towner->m_pFrameListener->OnKeyFrame(pLnpkf);\r\n\r\n\t\t\t\tnFramePos += sizeof(LANWPKGKEYFRAME);\r\n\t\t\t}\r\n\r\n\t\t\t/*\r\n\t\t\tif (LNPF_OPERATOR_SOURCE_FRMAE & pLnph->nPkgFlgs)\r\n\t\t\t{\r\n\t\t\t\tif (nFramePos + sizeof(LANWPKGSRCFRAME) > nReadLen)\r\n\t\t\t\t\tcontinue;\t// package too small\r\n\r\n\t\t\t\t//TODO: handle operator source frame here\r\n\t\t\t\tpLnpsf = (LANWPKGSRCFRAME *)(sPkgBuff + nFramePos);\r\n\t\t\t\tnFramePos += sizeof(LANWPKGSRCFRAME);\r\n\r\n\t\t\t\tif (LNPF_OTHER_SDN_FRAME & pLnph->nPkgFlgs)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (nFramePos + sizeof(LANWPKGTXTFRAME) < nReadLen)\r\n\t\t\t\t\t\tcontinue;\t// package too small\r\n\r\n\t\t\t\t\tpLnptf = (LANWPKGTXTFRAME *)(sPkgBuff + nFramePos);\r\n\t\t\t\t\tnFramePos += sizeof(LANWPKGTXTFRAME);\r\n\t\t\t\t\tif (owner->m_pFrameListener)\r\n\t\t\t\t\t\towner->m_pFrameListener->OnSourceFrame(pLnpsf, pLnptf->vText);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tif (owner->m_pFrameListener)\r\n\t\t\t\t\t\towner->m_pFrameListener->OnSourceFrame(pLnpsf, NULL);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (LNPF_OTHER_SOURCE_FRAME & pLnph->nPkgFlgs)\r\n\t\t\t{\r\n\t\t\t\tif (nFramePos + sizeof(LANWPKGSRCFRAME) < nReadLen)\r\n\t\t\t\t\tcontinue;\t// package too small\r\n\r\n\t\t\t\t//TODO: handle other source frame here\r\n\t\t\t\tpLnpsf = (LANWPKGSRCFRAME *)(sPkgBuff + nFramePos);\r\n\t\t\t\tnFramePos += sizeof(LANWPKGSRCFRAME);\r\n\r\n\t\t\t\tif (LNPF_OTHER_SDN_FRAME & pLnph->nPkgFlgs)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (nFramePos + sizeof(LANWPKGTXTFRAME) < nReadLen)\r\n\t\t\t\t\t\tcontinue;\t// package too small\r\n\r\n\t\t\t\t\tpLnptf = (LANWPKGTXTFRAME *)(sPkgBuff + nFramePos);\r\n\t\t\t\t\tnFramePos += sizeof(LANWPKGTXTFRAME);\r\n\t\t\t\t\tif (owner->m_pFrameListener)\r\n\t\t\t\t\t\towner->m_pFrameListener->OnSourceFrame(pLnpsf, pLnptf->vText);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tif (owner->m_pFrameListener)\r\n\t\t\t\t\t\towner->m_pFrameListener->OnSourceFrame(pLnpsf, NULL);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (LNPF_TEXT_FRAME & pLnph->nPkgFlgs)\r\n\t\t\t{\r\n\t\t\t\tif (nFramePos + sizeof(LANWPKGTXTFRAME) < nReadLen)\r\n\t\t\t\t\tcontinue;\t// package too small\r\n\r\n\t\t\t\t//TODO: handle text frame here\r\n\t\t\t\tpLnptf = (LANWPKGTXTFRAME *)(sPkgBuff + nFramePos);\r\n\t\t\t\tif (owner->m_pFrameListener)\r\n\t\t\t\t\towner->m_pFrameListener->OnTextFrame(pLnptf);\r\n\r\n\t\t\t\tnFramePos += sizeof(LANWPKGTXTFRAME);\r\n\t\t\t}\r\n\t\t\t*/\r\n\r\n\t\t\tif (nFramePos != nReadLen)\r\n\t\t\t{\r\n\t\t\t\t//TODO: handle invalid package here\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t} // end of if (SOCKET_ERROR != nReadLen && !owner->m_bNeedExit)\r\n\t\telse\r\n\t\t{\r\n\t\t\tint nErrCode = WSAGetLastError();\r\n\t\t}\r\n\t} // end of while(!owner->m_bNeedExit)\r\n\r\n\tif (owner->m_pEventListener)\r\n\t\towner->m_pEventListener->OnEvent(NM_EXIT);\r\n\r\n\treturn 0;\r\n}\r\n\r\nDWORD WINAPI CLaNetwork::NwSendThreadProc(LPVOID pOwner)\r\n{\r\n\tCLaNetwork* owner = (CLaNetwork *)pOwner;\r\n\tchar sPkgBuff[SEND_BUFF_BYTES];\r\n\tLANWPKGHEAD* pPkgHead = (LANWPKGHEAD *)sPkgBuff;\r\n\tLANWPKGKEYFRAME* pFrame = (LANWPKGKEYFRAME *)(sPkgBuff + sizeof(LANWPKGHEAD));\r\n\tsockaddr_in destAddr;\r\n\tdestAddr.sin_family = AF_INET;\r\n\r\n\twhile(!owner->m_bNeedExit)\r\n\t{\r\n\t\tif (owner->IsSendKeyFrameQueueEmpty())\r\n\t\t{\r\n\t\t\tSuspendThread(owner->m_hNwSendThread);\r\n\t\t\t// now send frame immediatly, but may be sleep here for keep alive frame in future\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tpPkgHead->nLaFlg = LA_FLAG;\r\n\t\t\tpPkgHead->nPkgFlgs = LNPF_KEY_FRAME;\r\n\r\n\t\t\towner->PickKeyFrame(pFrame);\r\n\r\n\t\t\tif (owner->m_pStbTabHead)\r\n\t\t\t\towner->SendKeyFrame(sPkgBuff, sizeof(LANWPKGHEAD) + sizeof(LANWPKGKEYFRAME)\r\n\t\t\t\t\t, &destAddr, owner->m_pStbTabHead);\r\n\r\n\t\t\t/* not supported dynamic node now\r\n\t\t\tif (owner->m_pDynTabHead)\r\n\t\t\t\towner->SendKeyFrame(sPkgBuff, sizeof(LANWPKGHEAD) + sizeof(LANWPKGKEYFRAME)\r\n\t\t\t\t\t, &destAddr, owner->m_pDynTabHead);\r\n\t\t\t*/\r\n\t\t}\r\n\t}\r\n\r\n\treturn 0;\r\n}\r\n\r\nBOOL CLaNetwork::SendKeyFrame(const char* pPkgBuff, int nLen, sockaddr_in* pAddr, const LANWSRCNODE* pHeadNode)\r\n{\r\n\tpAddr->sin_addr.s_addr = pHeadNode->base.nAddr;\r\n\tpAddr->sin_port = htons(pHeadNode->base.nPort);\r\n\r\n\tif (SOCKET_ERROR == sendto(m_socket, pPkgBuff, nLen, 0, (SOCKADDR *)pAddr, sizeof(sockaddr_in)))\r\n\t\treturn FALSE;\r\n\r\n\t/* only sent to every branch head\r\n\tif (NULL != pHeadNode->branch)\r\n\t\tif (!SendKeyFrame(pPkgBuff, nLen, pAddr, pHeadNode->branch))\r\n\t\t\treturn FALSE;*/\r\n\r\n\tif (NULL != pHeadNode->next)\r\n\t\treturn SendKeyFrame(pPkgBuff, nLen, pAddr, pHeadNode->next);\r\n\r\n\treturn TRUE;\r\n}\r\n"
  },
  {
    "path": "src/LaNetwork.h",
    "content": "#pragma once\r\n\r\n#define SEND_BUFF_BYTES\t\t128\r\n#define RECV_BUFF_BYTES\t\t128\r\n\r\n///ά֡/Ӧ֡\r\n#define LNPF_KEEPALIVE\t\t\t\t0x0000\r\n//֡\r\n#define LNPF_KEY_FRAME\t\t\t\t0x0001\r\n//ԴϢ֡\r\n#define LNPF_OPERATOR_SOURCE_FRMAE\t0x0002\r\n//ԴϢ֡֡\r\n#define LNPF_OPERATOR_SDN_FRMAE\t\t0x0004\r\n//ԴϢ֡\r\n#define LNPF_OTHER_SOURCE_FRAME\t\t0x0020\r\n//ԴϢ֡֡\r\n#define LNPF_OTHER_SDN_FRMAE\t\t0x0040\r\n//ɴֻϢ()\r\n#define LNPF_TEXT_FRAME\t\t\t\t0x0100\r\n//֡/תKEY_FRAME\r\n#define LNPF_SERVER_FRAME\t\t\t0x8000\r\n//\r\n#define LNPF_OFF_LINE\t\t\t\t0xffff\r\n\r\n#define LNPSF_OFF_LINE\t\t\t\t0x0000\r\n#define LNPSF_ON_LINE\t\t\t\t0x0001\r\n#define LNPSF_REQUEST\t\t\t\t0x0002\r\n//ǿ־\r\n#define LNPSF_SERVER\t\t\t\t0x0004\r\n//ǷתSERVER⣬Ҫתյİ\r\n#define LNPSF_BROKER\t\t\t\t0x0008\r\n\r\n#define NM_BIND_OK\t\t\t\t\t0x0010\r\n#define NM_BIND_FAILED\t\t\t\t0x8010\r\n#define NM_EXIT\t\t\t\t\t\t0x0030\r\n\r\n#define LRC_WSASTARTUP_FAILED\t\t0x8001\r\n\r\n#define SEND_QUEUE_SIZE\t\t\t\t100\r\n\r\n#define LA_FLAG\t\t\t\t\t\t((((WORD)'A') << 8) | ((WORD)'L'))\r\ntypedef struct\r\n{\r\n\tWORD\tnLaFlg;\t\t//'LA'\tLA_FLAG\r\n\tWORD\tnPkgFlgs;\t//LNPF_...\r\n} LANWPKGHEAD;\r\n\r\ntypedef struct\r\n{\r\n\tDWORD\tnToState : 1;\t// 0: off; 1: on\r\n\tDWORD\tnActTick : 31;\t// action tickcount\r\n\tDWORD\tnReserved;\t\t// 30,000,000\r\n} LANWPKGKEYFRAME;\r\n\r\ntypedef struct\r\n{\r\n\tWORD\tnSrcFlgs;\t//LNPSF_\r\n\tWORD\tnPort;\r\n\tDWORD\tnAddr;\r\n} LANWPKGSRCFRAME;\r\n\r\ntypedef struct\r\n{\r\n\tBYTE\tvText[32];\r\n} LANWPKGTXTFRAME;\r\n\r\ntypedef struct\r\n{\r\n\tlong\tnLastSendto;\t\t// ýڵʱ\r\n\tlong\tnLastRecvFrom;\t\t// Ըýڵʱ\r\n\tlong\tnSendPkgs;\t\t\t// ܰ\r\n\tlong\tnRecvPkgs;\t\t\t// ܰ\r\n} LANWSRCNODEATTR;\r\n\r\ntypedef struct tagLANWSRCNODE\r\n{\r\n\tLANWPKGSRCFRAME\t\t\tbase;\r\n\tLANWSRCNODEATTR\t\t\tattr;\r\n\tstruct tagLANWSRCNODE*\tbranch;\t// ͬһԴϵĽڵ⣬֧ڵֻbranch\r\n\tstruct tagLANWSRCNODE*\tnext;\t// ͬԴ\r\n} LANWSRCNODE;\r\n\r\nclass INetworkEventListener\r\n{\r\npublic:\r\n\tvirtual void OnEvent(WORD nMsg) = 0;\r\n};\r\n\r\nclass INetworkFrameListener\r\n{\r\npublic:\r\n\tvirtual void OnKeyFrame(const LANWPKGKEYFRAME* pFrame) = 0;\r\n\tvirtual void OnSourceFrame(const LANWPKGSRCFRAME* pFrame, const char* szDomainName) = 0;\r\n\tvirtual void OnTextFrame(const LANWPKGTXTFRAME* pFrame) = 0;\r\n};\r\n\r\n/**\r\n[STABLESOURCE]\r\nnode1=[www.layala.org:2009,x,x,x],[...],...\r\n**/\r\nclass CLaNetwork\r\n{\r\npublic:\r\n\tCLaNetwork(DWORD nFlgs);\r\n\t~CLaNetwork();\r\n\r\n\tBOOL Startup(WORD nPort);\r\n\tvoid Shutdown();\r\n\r\n\tvoid BindEventListener(INetworkEventListener* pEventListener) { m_pEventListener = pEventListener; };\r\n\tvoid BindFrameListener(INetworkFrameListener* pFrameListener) { m_pFrameListener = pFrameListener; };\r\n\r\n\tBOOL AppendKeyFrame(const LANWPKGKEYFRAME* pFrame);\r\n\tBOOL PickKeyFrame(LANWPKGKEYFRAME* pFrame);\r\n\tBOOL IsSendKeyFrameQueueEmpty() { return m_nSendInPos == m_nSendOutPos; };\r\n\t//void AppendTextFrameQ(const LANWPKGKEYFRAME* pFrame);\r\n\r\n\tBOOL AppendStbSrcNode(const LANWSRCNODE* pStbSrc);\r\n\tconst LANWSRCNODE* GetStbSrcList() { return m_pStbTabHead; };\r\n\r\nprivate:\r\n\r\n\t// \r\n\tDWORD\tm_nFlgs;\r\n\tWORD\tm_nLocalPort;\r\n\tBOOL\tm_bNeedExit;\r\n\r\n\t// CWͶ\r\n\tLANWPKGKEYFRAME\t\tm_vSendQ[SEND_QUEUE_SIZE];\r\n\tint\t\t\t\t\tm_nSendInPos;\t// Ƚ, λ\r\n\tint\t\t\t\t\tm_nSendOutPos;\t// ȳ, λ, InPosʱΪ\r\n\r\n\t// ̬ڵ\r\n\tLANWSRCNODE*\t\tm_pStbTabHead;\r\n\r\n\t// ̬ڵ\r\n\tLANWSRCNODE*\t\tm_pDynTabHead;\r\n\r\n\tINetworkEventListener*\tm_pEventListener;\r\n\tINetworkFrameListener*\tm_pFrameListener;\r\n\r\n\tBOOL\t\tm_bWsaInit;\r\n\tHANDLE\t\tm_hNwRecvThread;\r\n\tHANDLE\t\tm_hNwSendThread;\r\n\tDWORD\t\tm_nNwRecvThreadID;\r\n\tDWORD\t\tm_nNwSendThreadID;\r\n\tSOCKET\t\tm_socket;\r\n\r\n\tBOOL Bind(WORD nPort);\r\n\tstatic DWORD WINAPI NwRecvThreadProc(LPVOID pOwner);\r\n\tstatic DWORD WINAPI NwSendThreadProc(LPVOID pOwner);\r\n\tBOOL SendKeyFrame(const char* pPkgBuff, int nLen, sockaddr_in* pAddr, const LANWSRCNODE* pHeadNode);\r\n\tBOOL AppendNodeByAddr(const sockaddr* pAddr);\r\n};\r\n"
  },
  {
    "path": "src/LaSpectrogram.cpp",
    "content": "#include \"StdAfx.h\"\r\n#include \"LaSpectrogram.h\"\r\n\r\nCLaSpectrogram::CLaSpectrogram(IPaintableParent* pParent, const RECT* pRect, int nSamplePerSec, int nAnalyzeSamples)\r\n{\r\n\tm_nBorderWidth = 1;\r\n\tm_pFont = new CFont(\"Arial\", 8, CFont::THIN);\r\n\tm_pParent = pParent;\r\n\tm_oRect = *pRect;\r\n\tint w = m_oRect.right - m_oRect.left;\r\n\tint h = m_oRect.bottom - m_oRect.top;\r\n\tSetRect(&m_oPaintRect, m_nBorderWidth, m_nBorderWidth, w - m_nBorderWidth, h - m_nBorderWidth);\r\n\r\n\tm_nBgColor = 0x000000;\r\n\tm_nFrColor = 0xffff00;\r\n\r\n\tm_pPaintBoard = pParent->NewGraphics(m_oPaintRect.right - m_oPaintRect.left, m_oPaintRect.bottom - m_oPaintRect.top);\r\n\r\n\tm_nAnalyzeSamples = nAnalyzeSamples;\r\n\r\n\tm_bFraze = FALSE;\r\n\r\n\th = m_oPaintRect.bottom - m_oPaintRect.top;\r\n\tm_rPaintScale = (float)(h) / (float)m_nAnalyzeSamples;\r\n\tm_rPaintScaleNext = m_rPaintScale;\r\n\tm_rPaintIdx = 0;\r\n\tm_nCurrPos = 0;\r\n\tm_vFilterBuf = new float[h];\r\n\tm_nPhases = -1;\r\n\tm_nPhasesDiv = 512 / m_nAnalyzeSamples;\r\n\tm_bOrgSize = FALSE;\r\n}\r\n\r\nCLaSpectrogram::~CLaSpectrogram(void)\r\n{\r\n\tdelete[] m_vFilterBuf;\r\n\tdelete m_pFont;\r\n\tdelete m_pPaintBoard;\r\n}\r\n\r\nBOOL CLaSpectrogram::Initialize()\r\n{\r\n\treturn TRUE;\r\n}\r\n\r\nBOOL CLaSpectrogram::IsRelated(int x, int y)\r\n{\r\n\treturn IControl::PointInRect(&m_oRect, x, y);\r\n}\r\n\r\nvoid CLaSpectrogram::GetRect(RECT* r)\r\n{\r\n\t*r = m_oRect;\r\n}\r\n\r\nBOOL CLaSpectrogram::OnPaint(void* owner, CGraphics* g, const RECT* pRect)\r\n{\r\n\tint w = m_oPaintRect.right - m_oPaintRect.left;\r\n\tint h = m_oPaintRect.bottom - m_oPaintRect.top;\r\n\r\n\tRECT r = m_oPaintRect;\r\n\tr.right -= (m_nCurrPos + 1);\r\n\r\n\tif (m_nCurrPos < w - 1)\r\n\t{\r\n\t\tg->Copy(&r, m_pPaintBoard, m_nCurrPos + 1, 0);\r\n\t}\r\n\r\n\tr.left = r.right; r.right = r.left + m_nCurrPos + 1;\r\n\tg->Copy(&r, m_pPaintBoard, 0, 0);\r\n\r\n\tw = m_oRect.right - m_oRect.left - 1;\r\n\th = m_oRect.bottom - m_oRect.top - 1;\r\n\tg->SetColor(0x808080);\r\n\tg->DrawLine(0, 0, 0, h + 1);\r\n\tg->DrawLine(0, 0, w + 1, 0);\r\n\tg->SetColor(0xffffff);\r\n\tg->DrawLine(w, 0, w, h + 1);\r\n\tg->DrawLine(0, h, w + 1, h);\r\n\r\n\treturn TRUE;\r\n}\r\n\r\nshort int CLaSpectrogram::OnEncodeFilter(float val, int i)\r\n{\r\n\tif (0 == i)\r\n\t{\r\n\t\tif (++m_nPhases > m_nPhasesDiv)\r\n\t\t{\r\n\t\t\tRefresh();\r\n\t\t\tif (++m_nCurrPos >= m_oPaintRect.right - m_oPaintRect.left)\r\n\t\t\t\tm_nCurrPos = 0;\r\n\r\n\t\t\tm_nPhases = 0;\r\n\t\t\tm_rPaintScale = m_rPaintScaleNext;\r\n\t\t}\r\n\r\n\t\tm_rPaintIdx = 0.0f;\r\n\t}\r\n\r\n\tfloat currIdx = m_rPaintIdx;\r\n\tm_rPaintIdx += m_rPaintScale;\r\n\tfloat w = abs(val) * m_rPaintScale / 256.0f * m_rBrightnessScale;\r\n\tint j = (int)currIdx + 1;\r\n\r\n\tif (j < m_oPaintRect.bottom - m_oPaintRect.top)\r\n\t{\r\n\t\tfor (; j <= (int)m_rPaintIdx; currIdx = j++)\r\n\t\t{\r\n\t\t\tm_vFilterBuf[j - 1] += w * (j - currIdx);\r\n\t\t}\r\n\r\n\t\tm_vFilterBuf[j - 1] += w * (m_rPaintIdx - currIdx);\r\n\t}\r\n\r\n\r\n\treturn val;\r\n}\r\n\r\nvoid CLaSpectrogram::SetBrightness(float scale)\r\n{\r\n\tm_rBrightnessScale = pow(10.0f, scale / 20.0f);\r\n}\r\n\r\nshort int CLaSpectrogram::OnDecodeFilter(float val, int i)\r\n{\r\n\treturn val;\r\n}\r\n\r\n/***\r\n * ˢ¿ؼػߣȡƵݣ\r\n *\r\n */\r\nBOOL CLaSpectrogram::Refresh()\r\n{\r\n\tint h = m_oPaintRect.bottom - m_oPaintRect.top;\r\n\tint lval = min(abs(m_vFilterBuf[0]), 255);\r\n\tint lpos = 0, i;\r\n\r\n\tfor (i = lpos + 1; i < h; ++i)\r\n\t{\r\n\t\tif (lval != m_vFilterBuf[i])\r\n\t\t{\r\n\t\t\tm_pPaintBoard->SetColor(RGB(lval, lval, lval));\r\n\t\t\tm_pPaintBoard->DrawLine(m_nCurrPos, m_oPaintRect.bottom - (lpos + m_oPaintRect.top) - 1, m_nCurrPos, m_oPaintRect.bottom - (i + m_oPaintRect.top) - 1);\r\n\t\t\tlval = min(abs(m_vFilterBuf[i]), 255);\r\n\t\t\tlpos = i;\r\n\t\t}\r\n\r\n\t\tm_vFilterBuf[i] = 0;\r\n\t}\r\n\r\n\tif (i - 1 != lpos)\r\n\t{\r\n\t\tm_pPaintBoard->SetColor(RGB(0, 0, 0));\r\n\t\tm_pPaintBoard->DrawLine(m_nCurrPos, lpos, m_nCurrPos, h);\r\n\t}\r\n\r\n\tm_vFilterBuf[0] = 0;\r\n\t//RECT r = m_oPaintRect;\r\n\t//OffsetRect(&r, m_oRect.left, m_oRect.top);\r\n\tm_pParent->Invalidate(&m_oRect);\r\n\r\n\treturn TRUE;\r\n}\r\n\r\nBOOL CLaSpectrogram::OnMouseKeyDown(void* owner, MouseKeyType nMkt, int x, int y)\r\n{\r\n\tswitch(nMkt)\r\n\t{\r\n\t\tcase MouseKeyType::RBUTTON:\r\n\t\t{\r\n\t\t\tif (m_bOrgSize = !m_bOrgSize)\r\n\t\t\t{\r\n\t\t\t\tm_rPaintScaleNext = 1.0f;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tm_rPaintScaleNext = (m_oPaintRect.bottom - m_oPaintRect.top) / (float)m_nAnalyzeSamples;\r\n\t\t\t}\r\n\t\t\treturn TRUE;\r\n\t\t}\r\n\t\tcase MouseKeyType::LBUTTON:\r\n\t\t{\r\n\r\n\t\t\treturn TRUE;\r\n\t\t}\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nBOOL CLaSpectrogram::OnMouseKeyUp(void* owner, MouseKeyType nMkt, int x, int y)\r\n{\r\n\treturn FALSE;\r\n}\r\n\r\nvoid CLaSpectrogram::SetBackgroundColor(int nColor)\r\n{\r\n\tm_nBgColor = nColor;\r\n}\r\n\r\n"
  },
  {
    "path": "src/LaSpectrogram.h",
    "content": "#pragma once\r\n\r\n#include \"EventManagerWin32.h\"\r\n#include \"FFT.h\"\r\n#include \"dsound.h\"\r\n\r\n//log(32768)\r\n//#define LOG_SAMPLE_RANGE\t4.51545\t\r\n#define LOG_SAMPLE_RANGE\t4.51545f\r\n\r\nclass ICwEventListener;\r\n\r\nclass CLaSpectrogram\r\n\t: public IPaintEventControl\r\n\t, public IMouseKeyEventControl\r\n\t, public IFilterDFT<short int, float>\r\n{\r\npublic:\r\n\tCLaSpectrogram(IPaintableParent* pParent, const RECT* pRect, int nSamplePerSec, int nAnalyzeSample);\r\n\t~CLaSpectrogram(void);\r\n\r\n\tvirtual BOOL IsRelated(int x, int y);\r\n\tvirtual void GetRect(RECT* r);\r\n\tvirtual BOOL OnPaint(void* owner, CGraphics* g, const RECT* pRect);\r\n\r\n\tvirtual BOOL Initialize();\r\n\tvirtual BOOL Refresh();\r\n\r\n\tvirtual BOOL OnMouseKeyDown(void* owner, MouseKeyType nMkt, int x, int y);\r\n\tvirtual BOOL OnMouseKeyUp(void* owner, MouseKeyType nMkt, int x, int y);\r\n\tvirtual BOOL OnClick(void* owner) { return FALSE; };\r\n\r\n\tvirtual short int OnEncodeFilter(float val, int i);\r\n\tvirtual short int OnDecodeFilter(float val, int i);\r\n\r\n\tvoid SetBackgroundColor(int nColor);\r\n\tvoid SetFrontColor(int nColor);\r\n\r\n\tvoid SetBrightness(float scale);\r\n\r\nprivate:\r\n\tint AnalyzeData();\r\n\tDWORD GetSyncPos(short int* pBuff, DWORD nBuffSize);\r\n\r\n\tvoid DrawRuler();\r\n\tvoid DrawBorder();\r\n\tvoid DrawGrid();\r\n\r\n\tIPaintableParent*\t\tm_pParent;\r\n\tCFont*\t\tm_pFont;\r\n\tRECT\t\tm_oRect;\t// by parent\r\n\tRECT\t\tm_oPaintRect;\t// by self\r\n\tCGraphics*\tm_pPaintBoard;\r\n\tint\t\t\tm_nAnalyzeSamples;\r\n\r\n\tint\t\t\tm_nBorderWidth;\r\n\r\n\tint\t\t\tm_nBgColor;\r\n\tint\t\t\tm_nFrColor;\r\n\r\n\tBOOL\t\tm_bFraze;\r\n\r\n\tfloat*\t\tm_vFilterBuf;\r\n\tfloat\t\tm_rPaintIdx;\r\n\tint\t\t\tm_nCurrPos;\r\n\tfloat\t\tm_rPaintScale;\t// m_nAnalyzeSamples / canvos height\r\n\tfloat\t\tm_rPaintScaleNext;\r\n\tint\t\t\tm_nPhases;\r\n\tint\t\t\tm_nPhasesDiv;\r\n\tfloat\t\tm_rBrightnessScale;\r\n\tBOOL\t\tm_bOrgSize;\r\n};\r\n"
  },
  {
    "path": "src/LaTuner.cpp",
    "content": "#include \"StdAfx.h\"\r\n#include \"latuner.h\"\r\n#include \"FFT.h\"\r\n\r\nCLaTuner::CLaTuner(IPaintableParent* pParent, const char* pText, const RECT* pRect, LASCALE nScaleL, LASCALE nScaleR, LASCALE nScale, CFont* pFont)\r\n{\r\n\tInitButton(pParent, pRect, pText, nScaleL, nScaleR, nScale, pFont);\r\n}\r\n\r\nCLaTuner::~CLaTuner()\r\n{\r\n}\r\n\r\nvoid CLaTuner::SetScale(LASCALE nScale)\r\n{\r\n\tm_nScaleCurr = nScale;\r\n\tm_pParent->Invalidate(&m_oRect);\r\n}\r\n\r\nvoid CLaTuner::InitButton(IPaintableParent* pParent, const RECT* pRect, const char* pText, LASCALE nScaleL, LASCALE nScaleR, LASCALE nScale, CFont* pFont)\r\n{\r\n\tm_nIdxTxt = 0;\r\n\tm_pParent = pParent;\r\n\tm_oRect = *pRect;\r\n\tm_pFont = pFont;\r\n\r\n\tm_nScaleL = nScaleL;\r\n\tm_nScaleR = nScaleR;\r\n\tm_nScaleDiv = (nScaleR - nScaleL) / 256;\r\n\tm_nScaleDivD = 0;\r\n\tm_nScaleCurr = nScale;\r\n\r\n\tm_bMouseOver = FALSE;\r\n\tm_bRbuttonHold = FALSE;\r\n\tm_bLbuttonHold = FALSE;\r\n\r\n//\tm_pKeyboardEventListener = NULL;\r\n\tm_pMouseMoveEventListener = NULL;\r\n\tm_pMouseKeyEventListener = NULL;\r\n\tm_pTunerEventListener = NULL;\r\n\r\n\tResolveTextList(pText);\r\n\t\r\n\t((CEventDispatcherWin32 *)pParent)->AddTimerEventControl(this, LA_TUNER_HEARTBEAT_TIMER_ID, 60);\r\n}\r\n\r\nBOOL CLaTuner::IsRelated(int x, int y)\r\n{\r\n\tRECT rect = m_oRect;\r\n\tBOOL r = IControl::PointInRect(&rect, x, y);\r\n\tif (r != m_bMouseOver)\r\n\t{\r\n\t\tm_bMouseOver = r;\r\n\t\tm_pParent->Invalidate(&rect);\r\n\t}\r\n\r\n\treturn m_bRbuttonHold || m_bLbuttonHold || r;\r\n}\r\n\r\nvoid CLaTuner::GetRect(RECT* r)\r\n{\r\n\t*r = m_oRect;\r\n}\r\n\r\nBOOL CLaTuner::OnPaint(void* owner, CGraphics* g, const RECT* pRect)\r\n{\r\n\tchar buff[16];\r\n\tRECT a = m_oRect;\r\n\tOffsetRect(&a, -a.left, -a.top);\r\n\t\r\n\tg->SetBgColor(RGB(255, 255, 255));\r\n\r\n\tif (m_bMouseOver)\r\n\t{\r\n\t\tg->SetColor(RGB(0, 0, 0));\r\n\t}\r\n\telse\r\n\t{\r\n\t\tg->SetColor(RGB(127, 127, 127));\r\n\t}\r\n\r\n\tif (m_pFont)\r\n\t\tg->SetFont(m_pFont);\r\n\r\n\tRECT t = a;\r\n\tint r = (int)((a.bottom < a.right ? a.bottom : a.right) / 3.2f);\r\n\tint ox = a.right / 2;\r\n\tint oy = a.bottom / 2;\r\n\tt.left = ox - r;\r\n\tt.right = ox + r;\r\n\tt.top = oy - r;\r\n\tt.bottom = oy + r;\r\n\r\n\tg->DrawEllipse(&t);\r\n\tif (m_bMouseOver || m_bLbuttonHold || m_bRbuttonHold)\r\n\t{\r\n\t\tif (abs(m_nScaleR - m_nScaleL) > 20)\r\n\t\t\tsprintf(buff, \"%0.0f\", m_nScaleCurr);\r\n\t\telse if (abs(m_nScaleR - m_nScaleL) > 2)\r\n\t\t\tsprintf(buff, \"%0.1f\", m_nScaleCurr);\r\n\t\telse\r\n\t\t\tsprintf(buff, \"%0.2f\", m_nScaleCurr);\r\n\r\n\t\tg->DrawText(&t, buff, DT_VCENTER|DT_CENTER|DT_SINGLELINE);\r\n\t}\r\n\r\n\tint nScaleLen = r / 5;\r\n\tint nSplitWidth = nScaleLen / 2;\r\n\tfloat rx, ry;\r\n\tint nScaleCount = 10;\r\n\tfloat srad = 0.75f / nScaleCount;\r\n\tfor (int i = 0; i <= nScaleCount; ++i)\r\n\t{\r\n\t\trx = cosf(2 * PI * (i * srad + 0.375f));\r\n\t\try = sinf(2 * PI * (i * srad + 0.375f));\r\n\r\n\t\tif (0 == i || i == nScaleCount)\r\n\t\t{\r\n\t\t\tint tx = (int)(ox + (r + nScaleLen * 2 + nSplitWidth) * rx);\r\n\t\t\tint ty = (int)(oy + (r + nScaleLen * 2 + nSplitWidth) * ry);\r\n\t\t\tg->DrawLine((int)(ox + (r + nSplitWidth) * rx), (int)(oy + (r + nSplitWidth) * ry)\r\n\t\t\t\t, tx, ty);\r\n\t\t\t\r\n\t\t\tg->DrawLine(tx, ty, 0 == i ? 0 : a.right, ty);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tg->DrawLine((int)(ox + (r + nSplitWidth) * rx), (int)(oy + (r + nSplitWidth) * ry)\r\n\t\t\t\t, (int)(ox + (r + nScaleLen + nSplitWidth) * rx), (int)(oy + (r + nScaleLen + nSplitWidth) * ry));\r\n\t\t}\r\n\t}\r\n\r\n\tt.left = 0;\r\n\tt.right = ox - r;\r\n\tt.top = 0;\r\n\tt.bottom = oy + r + 0;\r\n\tsprintf(buff, \"%0.0f\", m_nScaleL);\r\n\tg->DrawText(&t, buff, DT_BOTTOM|DT_CENTER|DT_SINGLELINE, FALSE);\r\n\r\n\tt.left = ox + r + 2;\r\n\tt.right = a.right;\r\n\tsprintf(buff, \"%0.0f\", m_nScaleR);\r\n\tg->DrawText(&t, buff, DT_BOTTOM|DT_CENTER|DT_SINGLELINE, FALSE);\r\n\r\n\tLASCALE rd = 2 * PI * 0.75f * (m_nScaleCurr - m_nScaleL) / (m_nScaleR - m_nScaleL) + PI * 0.75f;\r\n\tint px = (int)((r - 8) * cosf(rd) + ox);\r\n\tint py = (int)((r - 8) * sinf(rd) + oy);\r\n\tt.left = px - 3;\r\n\tt.right = px + 3;\r\n\tt.top = py - 3;\r\n\tt.bottom = py + 3;\r\n\r\n\tg->DrawEllipse(&t);\r\n\r\n\tg->DrawText(&a, m_vText[m_nIdxTxt], DT_BOTTOM|DT_CENTER|DT_SINGLELINE, FALSE);\r\n\r\n\treturn TRUE;\r\n}\r\n\r\nBOOL CLaTuner::OnMouseMove(void* owner, int x, int y)\r\n{\r\n\treturn FALSE;\r\n}\r\n\r\nBOOL CLaTuner::OnMouseKeyDown(void* owner, MouseKeyType nMkt, int x, int y)\r\n{\r\n\tswitch(nMkt)\r\n\t{\r\n\tcase LBUTTON:\r\n\t\tm_bLbuttonHold = TRUE; break;\r\n\tcase RBUTTON:\r\n\t\tm_bRbuttonHold = TRUE; break;\r\n\tdefault:\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\tm_nScaleDivD = 0;\r\n\r\n\treturn TRUE;\r\n}\r\n\r\nBOOL CLaTuner::OnMouseKeyUp(void* owner, MouseKeyType nMkt, int x, int y)\r\n{\r\n\tswitch(nMkt)\r\n\t{\r\n\tcase LBUTTON:\r\n\t\tm_bLbuttonHold = FALSE; break;\r\n\tcase RBUTTON:\r\n\t\tm_bRbuttonHold = FALSE; break;\r\n\tdefault:\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\tm_nScaleDivD = 0;\r\n\r\n\tm_pParent->Invalidate(&m_oRect);\r\n\r\n\treturn TRUE;\r\n}\r\n\r\nBOOL CLaTuner::OnTimer(void* owner, int nTimerId)\r\n{\r\n\tif (LA_TUNER_HEARTBEAT_TIMER_ID == nTimerId\r\n\t\t&& m_bMouseOver)\r\n\t{\r\n\t\tif (m_bRbuttonHold)\r\n\t\t\tm_nScaleCurr += (m_nScaleDiv + m_nScaleDivD);\r\n\t\telse if (m_bLbuttonHold)\r\n\t\t\tm_nScaleCurr -= (m_nScaleDiv + m_nScaleDivD);\r\n\t\telse\r\n\t\t\treturn FALSE;\r\n\r\n\t\tm_nScaleDivD += m_nScaleDiv;\r\n\r\n\t\tif (m_nScaleDiv < 0)\r\n\t\t{\r\n\t\t\tif (m_nScaleCurr < this->m_nScaleR)\r\n\t\t\t\tm_nScaleCurr = m_nScaleR;\r\n\t\t\telse if (m_nScaleCurr > this->m_nScaleL)\r\n\t\t\t\tm_nScaleCurr = m_nScaleL;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tif (m_nScaleCurr < this->m_nScaleL)\r\n\t\t\t\tm_nScaleCurr = m_nScaleL;\r\n\t\t\telse if (m_nScaleCurr > this->m_nScaleR)\r\n\t\t\t\tm_nScaleCurr = m_nScaleR;\r\n\t\t}\r\n\t\t\r\n\t\tm_pParent->Invalidate(&m_oRect);\r\n\r\n\t\tif (m_pTunerEventListener)\r\n\t\t\tm_pTunerEventListener->OnTune(this, m_nScaleCurr);\r\n\r\n\t\treturn TRUE;\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\n/*void CLaTuner::AddKeyboardEventListener(IKeyboardEventListener* pListener)\r\n{\r\n\tm_pKeyboardEventListener = pListener;\r\n}*/\r\n\r\nvoid CLaTuner::AddMouseMoveEventListener(IMouseMoveEventListener* pListener)\r\n{\r\n\tm_pMouseMoveEventListener = pListener;\r\n}\r\n\r\nvoid CLaTuner::AddMouseKeyEventListener(IMouseKeyEventListener* pListener)\r\n{\r\n\tm_pMouseKeyEventListener = pListener;\r\n}\r\n\r\nvoid CLaTuner::AddTunerEventListener(ITunerEventListener* pListener)\r\n{\r\n\tm_pTunerEventListener = pListener;\r\n}\r\n\r\nvoid CLaTuner::ResolveTextList(const char* pText)\r\n{\r\n\tm_nCntTxt = 0;\r\n\tfor (int i = 0, j; '\\0' != pText[i]; i = j, ++m_nCntTxt)\r\n\t{\r\n\t\tfor (j = i; '\\0' != pText[j] && ',' != pText[j]; ++j)\r\n\t\t{\r\n\t\t}\r\n\r\n\t\tm_vText.push_back(new char[j - i + 1]);\r\n\t\tstrncpy(m_vText[m_nCntTxt], pText + i, j - i);\r\n\t\tm_vText[m_nCntTxt][j - i] = '\\0';\r\n\r\n\t\tif (',' == pText[j])\r\n\t\t\t++j;\r\n\t}\r\n\r\n\tm_nIdxTxt = 0;\r\n}\r\n\r\n"
  },
  {
    "path": "src/LaTuner.h",
    "content": "#pragma once\r\n\r\n#include \"EventManagerWin32.h\"\r\n\r\n#define LA_TUNER_HEARTBEAT_TIMER_ID\t\t10060\r\ntypedef float\tLASCALE;\r\n\r\nclass ITunerEventListener\r\n{\r\npublic:\r\n\tvirtual BOOL OnTune(void* owner, LASCALE nScale) = 0;\r\n};\r\n\r\nclass CLaTuner\r\n\t: public IPaintEventControl\r\n\t, public IMouseMoveEventControl\r\n\t, public IMouseKeyEventControl\r\n\t, public ITimerEventControl\r\n{\r\npublic:\r\n\tCLaTuner(IPaintableParent* pParent, const char* pText, const RECT* pRect, LASCALE nScaleL, LASCALE nScaleR, LASCALE nScale, CFont* pFont);\r\n\tvirtual ~CLaTuner();\r\n\r\n\tvirtual BOOL IsRelated(int x, int y);\r\n\tvirtual void GetRect(RECT* r);\r\n\tvirtual BOOL OnPaint(void* owner, CGraphics* g, const RECT* pRect);\r\n\tvirtual BOOL OnMouseMove(void* owner, int x, int y);\r\n\tvirtual BOOL OnMouseKeyDown(void* owner, MouseKeyType nMkt, int x, int y);\r\n\tvirtual BOOL OnMouseKeyUp(void* owner, MouseKeyType nMkt, int x, int y);\r\n\tvirtual BOOL OnTimer(void* owner, int nTimerId);\r\n\tvirtual BOOL OnClick(void* owner) { return FALSE; };\r\n\r\n//\tvoid AddKeyboardEventListener(IKeyboardEventListener* pListener);\r\n\tvoid AddMouseMoveEventListener(IMouseMoveEventListener* pListener);\r\n\tvoid AddMouseKeyEventListener(IMouseKeyEventListener* pListener);\r\n\tvoid AddTunerEventListener(ITunerEventListener* pListener);\r\n\tvoid SetScale(LASCALE nScale);\r\n\tLASCALE GetScale() { return m_nScaleCurr; };\r\n\r\nprivate:\r\n\tIPaintableParent*\t\tm_pParent;\r\n\r\n\tCFont*\t\tm_pFont;\r\n\tvector<char *>\t\tm_vText;\r\n\tRECT\tm_oRect;\r\n\tLASCALE\tm_nScaleL;\r\n\tLASCALE\tm_nScaleR;\r\n\tLASCALE\tm_nScaleDiv;\r\n\tLASCALE\tm_nScaleDivD;\r\n\tLASCALE\tm_nScaleCurr;\r\n\r\n\tBOOL\tm_bMouseOver;\r\n\tBOOL\tm_bRbuttonHold;\r\n\tBOOL\tm_bLbuttonHold;\r\n\tint\t\tm_nIdxTxt;\r\n\tint\t\tm_nCntTxt;\r\n\r\n//\tIKeyboardEventListener*\t\tm_pKeyboardEventListener;\r\n\tIMouseMoveEventListener*\tm_pMouseMoveEventListener;\r\n\tIMouseKeyEventListener*\t\tm_pMouseKeyEventListener;\r\n\tITunerEventListener*\t\tm_pTunerEventListener;\r\n\r\n\tvoid*\tm_pUserData;\r\n\r\n\tvoid InitButton(IPaintableParent* pParent, const RECT* pRect, const char* pText, LASCALE nScaleL, LASCALE nScaleR, LASCALE nScale, CFont* pFont);\r\n\tvoid ResolveTextList(const char* pText);\r\n};\r\n"
  },
  {
    "path": "src/LaWaveCapture.cpp",
    "content": "#include \"StdAfx.h\"\r\n#include \"lawavecapture.h\"\r\n#include \"sinsound.h\"\r\n\r\nCLaWaveCapture::CLaWaveCapture(IPaintableParent* pParent, const RECT* pRect, int nSamplePerSec, int nAnalyzeSamples, IFilterDFT<short int, float>* pNextFilter, ICwEventListener* pCwEventListener/* = NULL */)\r\n{\r\n\tm_bRulerInvalid = TRUE;\r\n\tm_nBorderWidth = 1;\r\n\tm_nRularH = 9;\r\n\tm_nRularV = 16;\r\n\tm_pFont = new CFont(\"Arial\", 8, CFont::THIN);\r\n\tm_nWaveState = WAVE_ORIGINAL;\r\n\tm_nDctState = DCT_LOG10_FLOAT;\r\n\tm_nWaveStateTip = 0;\r\n\tm_nDctStateTip = 0;\r\n\tm_pParent = pParent;\r\n\tm_oRect = *pRect;\r\n\tint w = m_oRect.right - m_oRect.left;\r\n\tint h = m_oRect.bottom - m_oRect.top;\r\n\tSetRect(&m_oPaintRect, m_nBorderWidth, m_nBorderWidth, w - m_nRularV - m_nBorderWidth, h - m_nRularH - m_nBorderWidth);\r\n\tSetRect(&m_oRulerRectH, m_nBorderWidth, h - m_nRularH - m_nBorderWidth, w - m_nRularV - m_nBorderWidth, h - m_nBorderWidth);\r\n\tSetRect(&m_oRulerRectV, m_oPaintRect.right, m_oPaintRect.top, w - m_nBorderWidth, h - m_nRularH - m_nBorderWidth);\r\n\tm_nRulerWidthH = w - m_nRularV - m_nBorderWidth * 2;\r\n\tm_nRulerWidthV = h - m_nRularH - m_nBorderWidth * 2;\r\n\tm_nRulerGridsV = (100 < m_nRulerWidthV ? 8 : 4);\r\n\tm_nRulerDbMax = 80;\r\n\r\n\tm_nBgColor = 0x000000;\r\n\tm_nWaveColor = 0x00f000;\r\n\tm_nFreqAnaColor = 0x808080;\r\n\tm_nFloatColor = 0xf0f0f0;\r\n\tm_nRulerColorH = 0x008000;\r\n\tm_nRulerColorV = 0x008080;\r\n\tm_nGridColorH = 0x000080;\r\n\tm_nGridColorV = 0x004040;\r\n\tm_nEnabledColor = 0x00f000;\r\n\tm_nDisabledColor = 0x808080;\r\n\r\n\tm_pPaintBoard = pParent->NewGraphics(pRect->right - pRect->left, pRect->bottom - pRect->top);\r\n\r\n\tm_pCwEventListener = pCwEventListener;\r\n\r\n\tm_pDsCap = NULL;\r\n\tm_pDsCapBuff = NULL;\r\n\r\n\tmemset(&m_oFormat, 0, sizeof(m_oFormat)); \r\n\tm_oFormat.wFormatTag = WAVE_FORMAT_PCM;\r\n\tm_oFormat.nChannels = 1;\r\n\tm_oFormat.nSamplesPerSec = nSamplePerSec;\r\n\tm_oFormat.wBitsPerSample = 16;\r\n\tm_oFormat.nAvgBytesPerSec = m_oFormat.nSamplesPerSec * (m_oFormat.wBitsPerSample / 8) * m_oFormat.nChannels;\r\n\tm_oFormat.nBlockAlign = m_oFormat.wBitsPerSample / 8 * m_oFormat.nChannels;\r\n\tm_oFormat.cbSize = 0;\r\n\r\n\tmemset(&m_oCaptureBufferDesc, 0, sizeof(m_oCaptureBufferDesc));\r\n\tm_oCaptureBufferDesc.dwSize = sizeof(m_oCaptureBufferDesc);\r\n\tm_oCaptureBufferDesc.dwFlags = 0;\r\n\tm_oCaptureBufferDesc.dwBufferBytes = m_oFormat.nAvgBytesPerSec * 2;\t// 2 sec buffer\r\n\tm_oCaptureBufferDesc.lpwfxFormat = &m_oFormat;\r\n\tm_oCaptureBufferDesc.dwFXCount = 0;\r\n\tm_oCaptureBufferDesc.lpDSCFXDesc = NULL;\r\n\r\n\tm_nAnalyzeSamples = nAnalyzeSamples;\r\n\tm_pWavBuff = new short int[m_nAnalyzeSamples * 2];\r\n\tm_pDctBuff = new short int[m_nAnalyzeSamples];\r\n\tm_pFreqRuler = new short int[m_nRulerWidthH];\r\n\tm_pFloatLine = new short int[m_nAnalyzeSamples];\r\n\tm_pFloatClear = new short int[m_nAnalyzeSamples];\r\n\tmemset(m_pFloatLine, 0, sizeof(short int) * m_nAnalyzeSamples);\r\n\tmemset(m_pFloatClear, 0, sizeof(short int) * m_nAnalyzeSamples);\r\n\t//m_nFloatClear = 0;\r\n\r\n\t//DrawRuler();\r\n\tDrawBorder();\r\n\r\n\tm_nRecvThreshold = (short int)(32768 * 0.5l);\r\n\tm_nRecvFreqStart = 850;\r\n\tm_nRecvFreqEnd = 1250;\r\n\r\n//\tm_pFft = new TCosDFT<short int, float>(m_nAnalyzeSamples, this);\r\n\tm_pFft = new TFastFT<short int, float>(m_nAnalyzeSamples, this);\r\n\tm_pNextFilter = pNextFilter;\r\n\r\n\tm_bFraze = FALSE;\r\n\r\n\tInitTestBuffer();\r\n\tm_nTestIndex = 0;\r\n}\r\n\r\nCLaWaveCapture::~CLaWaveCapture(void)\r\n{\r\n\tdelete m_pFont;\r\n\tdelete m_pPaintBoard;\r\n\r\n\tif (NULL != m_pDsCap)\r\n\t{\r\n\t\tif (NULL != m_pDsCapBuff)\r\n\t\t{\r\n\t\t\tm_pDsCapBuff->Release();\r\n\t\t\tm_pDsCapBuff = NULL;\r\n\t\t}\r\n\r\n\t\tm_pDsCap->Release();\r\n\t\tm_pDsCap = NULL;\r\n\t}\r\n\r\n\tdelete[] m_pWavBuff;\r\n\tdelete[] m_pDctBuff;\r\n\tdelete[] m_pFreqRuler;\r\n\tdelete[] m_pFloatLine;\r\n\tdelete[] m_pFloatClear;\r\n\r\n\tdelete[] m_pTestBuff;\r\n}\r\n\r\nvoid CLaWaveCapture::SetThresholdLevel(double rThresholdLevel)\r\n{\r\n\tm_nRecvThreshold = (short int)(32768 * rThresholdLevel);\r\n}\r\n\r\nvoid CLaWaveCapture::SetFreqRange(int nLowFreq, int nHighFreq)\r\n{\r\n\tm_nRecvFreqStart = nLowFreq;\r\n\tm_nRecvFreqEnd = nHighFreq;\r\n}\r\n\r\nvoid CLaWaveCapture::DrawRuler()\r\n{\r\n\tm_bRulerInvalid = FALSE;\r\n\tdouble rTotalLogNum = log10(16000.0l) - 2;\r\n\tfor (int i = 0; i < m_nRulerWidthH; ++i)\r\n\t{\r\n\t\tm_pFreqRuler[i] = (short int)pow(10, 2 + (i * rTotalLogNum / m_nRulerWidthH));\r\n\t}\r\n\r\n\tm_pPaintBoard->SetBgColor(m_nBgColor);\r\n\tm_pPaintBoard->DrawRect(&m_oRulerRectH);\r\n\tm_pPaintBoard->SetColor(m_nRulerColorH);\r\n\tm_pPaintBoard->DrawLine(m_oRulerRectH.left, m_oRulerRectH.top, m_oRulerRectH.right, m_oRulerRectH.top);\r\n\tm_pPaintBoard->SetFont(m_pFont);\r\n\tdouble d = m_nRulerWidthH / rTotalLogNum;\r\n\tRECT r = m_oRulerRectH;\r\n//\tRECT tr;\r\n\tchar grad[8];\r\n\tr.top += 1;\r\n\tfor (int i = 0; i < rTotalLogNum; ++i)\r\n\t{\r\n\t\tr.left = (int)(d * i);\r\n\r\n\t\tif (0 == i)\r\n\t\t\tsprintf(grad, \"%.0lfHz\", pow(10.0, i + 2));\r\n\t\telse if (3 > i + 2)\r\n\t\t\tsprintf(grad, \"%.0lf\", pow(10.0, i + 2));\r\n\t\telse\r\n\t\t\tsprintf(grad, \"%.0lfK\", pow(10.0, i + 2) / 1000);\r\n\r\n\t\t//m_pPaintBoard->SetColor(RGB(192, 192, 192));\r\n\t\tr.left += 2;\r\n\t\tm_pPaintBoard->DrawText(&r, grad, DT_LEFT);\r\n\t\tr.left -= 2;\r\n\t\t//m_pPaintBoard->SetColor(RGB(224, 224, 224));\r\n\t\tm_pPaintBoard->DrawLine(r.left, 0 == i ? 0 : m_oRulerRectH.top + 1, r.left, m_oRulerRectH.bottom - 1);\r\n\r\n\t\tif (4 > i)\r\n\t\t{\r\n\t\t\tfor (int j = 2; j < 6 && r.left < m_nRulerWidthH; ++j)\r\n\t\t\t{\r\n\t\t\t\tr.left = (int)(d * (i + log10((double)j)));\r\n\r\n\t\t\t\tsprintf(grad, \"%d\", j);\r\n\r\n//\t\t\t\tm_pPaintBoard->SetColor(m_nFreqAnaColor);\r\n\t\t\t\tr.left += 2;\r\n\t\t\t\tm_pPaintBoard->DrawText(&r, grad, DT_LEFT);\r\n\t\t\t\tr.left -= 2;\r\n//\t\t\t\tm_pPaintBoard->SetColor(m_nFreqAnaColor);\r\n\t\t\t\tm_pPaintBoard->DrawLine(r.left, m_oRulerRectH.top + 1, r.left, m_oRulerRectH.bottom - 2);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// draw rular-V\r\n\tm_pPaintBoard->SetBgColor(m_nBgColor);\r\n\tm_pPaintBoard->DrawRect(&m_oRulerRectV);\r\n\tm_pPaintBoard->DrawLine(m_oRulerRectV.left, m_oRulerRectV.top, m_oRulerRectV.left, m_oRulerRectV.bottom);\r\n\r\n\tswitch(m_nDctState)\r\n\t{\r\n\tcase DCT_LOG10_FLOAT:\r\n\tcase DCT_LOG10:\r\n\t\tm_pPaintBoard->SetColor(m_nRulerColorV);\r\n\t\tr = m_oRulerRectV;\r\n\t\tr.bottom = r.top + m_nRularV;\r\n\t\tm_pPaintBoard->DrawText(&r, \"dB\", DT_CENTER);\r\n\t\t//r.top -= 3;\r\n\r\n\t\tfor (int i = 1; i <= m_nRulerGridsV; ++i)\r\n\t\t{\r\n\t\t\tr.top = m_oRulerRectV.top + i * m_nRulerWidthV / m_nRulerGridsV - 3;\r\n\t\t\tr.bottom = r.top + m_nRularV;\r\n\t\t\t//OffsetRect(&r, 0, m_nRulerWidthV / m_nRulerGridsV);\r\n\t\t\tsprintf(grad, \"-%d\", i * m_nRulerDbMax / m_nRulerGridsV);\r\n\t\t\tm_pPaintBoard->DrawText(&r, grad, DT_CENTER);\r\n\t\t}\r\n\t\tbreak;\r\n\tcase DCT_LINEAR_FLOAT:\r\n\tcase DCT_LINEAR:\r\n\t\tm_pPaintBoard->SetColor(m_nRulerColorV);\r\n\t\tr = m_oRulerRectV;\r\n\t\tr.bottom = m_nRularV;\r\n\t\tm_pPaintBoard->DrawText(&r, \"%\", DT_CENTER);\r\n\t\tr.top -= 3;\r\n\r\n\t\tfor (int i = 2; i <= m_nRulerGridsV; i+=2)\r\n\t\t{\r\n\t\t\tOffsetRect(&r, 0, m_nRulerWidthV * 2 / m_nRulerGridsV);\r\n\t\t\tsprintf(grad, \"%d\", 100 - i * 100 / m_nRulerGridsV);\r\n\t\t\tm_pPaintBoard->DrawText(&r, grad, DT_CENTER);\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n}\r\n\r\nvoid CLaWaveCapture::DrawBorder()\r\n{\r\n\tint w = m_oRect.right - m_oRect.left - 1;\r\n\tint h = m_oRect.bottom - m_oRect.top - 1;\r\n\tm_pPaintBoard->SetColor(0x808080);\r\n\tm_pPaintBoard->DrawLine(0, 0, 0, h + 1);\r\n\tm_pPaintBoard->DrawLine(0, 0, w + 1, 0);\r\n\tm_pPaintBoard->SetColor(0xffffff);\r\n\tm_pPaintBoard->DrawLine(w, 0, w, h + 1);\r\n\tm_pPaintBoard->DrawLine(0, h, w + 1, h);\r\n}\r\n\r\nvoid CLaWaveCapture::DrawGrid()\r\n{\r\n\tm_pPaintBoard->SetColor(m_nGridColorV);\r\n\tfor (int i = 1; i < m_nRulerGridsV; ++i)\r\n\t{\r\n\t\tm_pPaintBoard->DrawLineDot(m_oPaintRect.left, m_nBorderWidth + i * m_nRulerWidthV / m_nRulerGridsV, m_oPaintRect.right, m_nBorderWidth + i * m_nRulerWidthV / m_nRulerGridsV);\r\n\t}\r\n}\r\nBOOL CLaWaveCapture::Initialize()\r\n{\r\n\tm_nNextPeriodStartPos = -1;\r\n\r\n\tif (FAILED(DirectSoundCaptureCreate8(NULL, &m_pDsCap, NULL)))\r\n\t\treturn FALSE;\r\n\r\n\tif (FAILED(m_pDsCap->CreateCaptureBuffer(&m_oCaptureBufferDesc, &m_pDsCapBuff, NULL)))\r\n\t\treturn FALSE;\r\n\r\n\treturn FAILED(m_pDsCapBuff->Start(DSCBSTART_LOOPING));\r\n}\r\n\r\nBOOL CLaWaveCapture::IsRelated(int x, int y)\r\n{\r\n\treturn IControl::PointInRect(&m_oRect, x, y);\r\n}\r\n\r\nvoid CLaWaveCapture::GetRect(RECT* r)\r\n{\r\n\t*r = m_oRect;\r\n}\r\n\r\nBOOL CLaWaveCapture::OnPaint(void* owner, CGraphics* g, const RECT* pRect)\r\n{\r\n\tint w = m_oRect.right - m_oRect.left;\r\n\tint h = m_oRect.bottom - m_oRect.top;\r\n\r\n\tRECT r;\r\n\tr.top = 0; r.bottom = h;\r\n\tr.left = 0; r.right = w;\r\n\tg->Copy(&r, m_pPaintBoard, 0, 0);\r\n\r\n\treturn TRUE;\r\n}\r\n\r\n#define TRANSFORM_SAMPLE(f, t)\t\t\t\t\\\r\n\tint x = f;\t\t\t\t\t\t\t\t\\\r\n\tx <<= (m_nWaveState - WAVE_ORIGINAL);\t\\\r\n\tif (x > 32767)\t\t\t\t\t\t\t\\\r\n\t\tx = 32767;\t\t\t\t\t\t\t\\\r\n\telse if (x < -32767)\t\t\t\t\t\\\r\n\t\tx = -32767;\t\t\t\t\t\t\t\\\r\n\tt = m_oPaintRect.top + (m_oPaintRect.bottom - m_oPaintRect.top) / 2 - x * (m_oPaintRect.bottom - m_oPaintRect.top) / 65536;\r\n\r\nint CLaWaveCapture::AnalyzeData()\r\n{\r\n\tDWORD nStatus = 0;\r\n\r\n\tif (!m_pDsCapBuff)\r\n\t\treturn -1;\r\n\r\n\tm_pDsCapBuff->GetStatus(&nStatus);\r\n\tif (!((DSCBSTATUS_CAPTURING & nStatus) && (DSCBSTATUS_LOOPING & nStatus)))\r\n\t\treturn -1;\r\n\r\n\tDWORD nReadPosEnd;\r\n\tDWORD nCapturePos;\r\n\tint nFrameBytes = m_nAnalyzeSamples * sizeof(short int);\r\n\tif (FAILED(m_pDsCapBuff->GetCurrentPosition(&nCapturePos, &nReadPosEnd)))\r\n\t\treturn -1;\r\n\r\n\t// get read start pos\r\n\t//int nReadPosStart = m_nNextPeriodStartPos;\r\n\tif (0 > m_nNextPeriodStartPos)\r\n\t{\r\n\t\t// always read 1 frame data at first time since buffer be init\r\n\t\tm_nNextPeriodStartPos = nReadPosEnd - nFrameBytes * 2;\r\n\t\tif (0 > m_nNextPeriodStartPos)\r\n\t\t\tm_nNextPeriodStartPos += m_oCaptureBufferDesc.dwBufferBytes;\r\n\t}\r\n\r\n\t// calc bytes should be read\r\n\tint nReadBytes = nReadPosEnd - m_nNextPeriodStartPos;\r\n\tif (nReadBytes < 0)\r\n\t\tnReadBytes += m_oCaptureBufferDesc.dwBufferBytes;\r\n\r\n\tint nReadTimes = nReadBytes / (nFrameBytes * 2);\r\n\tif (0 == nReadTimes)\r\n\t\treturn -1;\r\n\r\n\t// correct read bytes\r\n\tnReadBytes = nReadTimes * nFrameBytes * 2;\r\n\r\n\tshort int *pHeadPortion, *pTailPortion;\r\n\tDWORD nHpBytes, nTpBytes;\r\n\tif (FAILED(m_pDsCapBuff->Lock(m_nNextPeriodStartPos, nReadBytes, (LPVOID *)&pHeadPortion, &nHpBytes, (LPVOID *)&pTailPortion, &nTpBytes, 0)))\r\n\t\treturn -1;\r\n\r\n\tDWORD i, nBase = 0;\r\n\tBOOL bTestFlg = FALSE; //(0 == (++m_nTestInt / 10) % 2);\r\n\tint s = 0;\r\n\tfor (int nFrame = 0; nFrame < nReadTimes; ++nFrame)\r\n\t{\r\n\t\tfor (i = 0; i < nFrameBytes && (nBase + i) < nHpBytes / sizeof(short int); ++i)\r\n\t\t{\r\n\t\t\tm_pWavBuff[i] = pHeadPortion[nBase + i];\r\n\t\t\ts += abs(m_pWavBuff[i]);\r\n\r\n\t\t\tif (bTestFlg)\r\n\t\t\t{\r\n\t\t\t\tif (++m_nTestIndex == m_nTestBuffLen)\r\n\t\t\t\t\tm_nTestIndex = 0;\r\n\r\n\t\t\t\tint t = (int)m_pWavBuff[i] + (int)m_pTestBuff[m_nTestIndex];\r\n\t\t\t\tm_pWavBuff[i] = min(32767, t);\r\n\t\t\t\tm_pWavBuff[i] = max(-32767, t);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// nFrameBytes same as (nFrameBytes * 2 / sizeof(short int))\r\n\t\tfor (; i < nFrameBytes; ++i)\r\n\t\t{\r\n\t\t\tm_pWavBuff[i] = pTailPortion[nBase + i];\r\n\t\t\ts += abs(m_pWavBuff[i]);\r\n\r\n\t\t\tif (bTestFlg)\r\n\t\t\t{\r\n\t\t\t\tif (++m_nTestIndex == m_nTestBuffLen)\r\n\t\t\t\t\tm_nTestIndex = 0;\r\n\r\n\t\t\t\tint t = (int)m_pWavBuff[i] + (int)m_pTestBuff[m_nTestIndex];\r\n\t\t\t\tm_pWavBuff[i] = min(32767, t);\r\n\t\t\t\tm_pWavBuff[i] = max(-32767, t);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t//static int dddd = 100;\r\n\t\t//_ASSERT(dddd != 0 || 0 != s);\r\n\t\t//if (0 < dddd)\r\n\t\t//\t--dddd;\r\n\r\n\t\tm_nCwState = FALSE;\r\n\t\tm_pFft->Encode(m_pDctBuff, m_pWavBuff);\r\n\t\t//m_pFft->Decode(m_pWavBuff, m_pDctBuff);\r\n\t\tif (NULL != m_pCwEventListener)\r\n\t\t\tm_pCwEventListener->OnCwEvent(m_nCwState);\r\n\r\n\t\tm_nCwState = FALSE;\r\n\t\tm_pFft->Encode(m_pDctBuff, m_pWavBuff + m_nAnalyzeSamples);\r\n\t\t//m_pFft->Decode(m_pWavBuff + m_nAnalyzeSamples, m_pDctBuff);\r\n\t\tif (NULL != m_pCwEventListener)\r\n\t\t\tm_pCwEventListener->OnCwEvent(m_nCwState);\r\n\r\n\t\tnBase += nFrameBytes;\r\n\t}\r\n\r\n\tm_pDsCapBuff->Unlock(pHeadPortion, nHpBytes, pTailPortion, nTpBytes);\r\n\r\n\tif ((m_nNextPeriodStartPos += nReadBytes) >= m_oCaptureBufferDesc.dwBufferBytes)\r\n\t\tm_nNextPeriodStartPos -= m_oCaptureBufferDesc.dwBufferBytes;\r\n\r\n\treturn GetSyncPos(m_pWavBuff, m_nAnalyzeSamples);\r\n}\r\n\r\nshort int CLaWaveCapture::OnEncodeFilter(float val, int i)\r\n{\r\n\tif (!m_nCwState && m_nRecvThreshold <= abs(val))\r\n\t{\r\n\t\tint nFreq = i * m_oFormat.nSamplesPerSec / 2 / m_nAnalyzeSamples;\r\n\t\tif (m_nRecvFreqStart <= nFreq && nFreq <= m_nRecvFreqEnd)\r\n\t\t\tm_nCwState = TRUE;\r\n\t}\r\n\r\n\tif (m_pNextFilter)\r\n\t\treturn m_pNextFilter->OnEncodeFilter(val, i);\r\n\r\n\treturn val;\r\n}\r\n\r\nshort int CLaWaveCapture::OnDecodeFilter(float val, int i)\r\n{\r\n\treturn val;\r\n}\r\n\r\n/***\r\n * ˢ¿ؼػߣȡƵݣ\r\n *\r\n */\r\nBOOL CLaWaveCapture::Refresh()\r\n{\r\n\tif (m_bRulerInvalid)\r\n\t\tDrawRuler();\r\n\r\n\tint nSyncStart = AnalyzeData();\r\n\r\n\tif (0 > nSyncStart)\r\n\t\treturn FALSE;\r\n\r\n\tif (m_bFraze)\r\n\t\treturn TRUE;\r\n\t// redraw data if need\r\n\r\n\tm_pPaintBoard->SetColor(m_nBgColor);\r\n\t//m_oPaintRect.left += 1;\r\n\tm_pPaintBoard->DrawRect(&m_oPaintRect);\r\n\t//m_oPaintRect.left -= 1;\r\n\r\n\tDrawGrid();\r\n\r\n\tm_pPaintBoard->SetColor(m_nWaveColor);\r\n\tshort int* pSyncWavBuff = m_pWavBuff + nSyncStart;\r\n\r\n\tint last, curr;\r\n\tTRANSFORM_SAMPLE(pSyncWavBuff[0], last);\r\n\r\n\tint i, x1, x2 = m_nBorderWidth;\r\n\tfor (i = 1; m_nWaveState && i < m_nAnalyzeSamples; ++i)\r\n\t{\r\n\t\tint v = pSyncWavBuff[i];\r\n\t\tTRANSFORM_SAMPLE(v, curr);\r\n\t\tx1 = x2;\r\n\t\tx2 = m_nBorderWidth + m_nRulerWidthH * i / m_nAnalyzeSamples;\r\n\t\tm_pPaintBoard->DrawLine(x1, last, x2, curr);\r\n\t\tlast = curr;\r\n\t}\r\n\r\n\tm_pPaintBoard->SetColor(m_nFreqAnaColor);\r\n\r\n\t//FFT\r\n\t//m_pFft->Compute(m_pDctBuff, pSyncWavBuff);\r\n\r\n\t//m_pPaintBoard->SetColor(RGB(0, 0, 0));\r\n\tint fd, v, l = 1;\r\n\tfloat db;\r\n//\tBOOL bState = FALSE;\r\n\tfor (i = 0; i < m_nAnalyzeSamples; i += 2)\r\n\t{\r\n\t\tshort int nFreq = (short int)(i * m_oFormat.nSamplesPerSec / 2 / m_nAnalyzeSamples);\r\n\t\tfor (; m_nDctState && l < m_nRulerWidthH; ++l)\r\n\t\t{\r\n\t\t\tif (m_pFreqRuler[l] >= nFreq)\r\n\t\t\t{\r\n\t\t\t\tv = 0;\r\n\t\t\t\tswitch (m_nDctState)\r\n\t\t\t\t{\r\n\t\t\t\t\tcase DCT_LINEAR:\r\n\t\t\t\t\tcase DCT_LINEAR_FLOAT:\r\n\t\t\t\t\t\tv = abs(m_pDctBuff[i]) * m_oPaintRect.bottom / 32768;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase DCT_LOG10:\r\n\t\t\t\t\tcase DCT_LOG10_FLOAT:\r\n\t\t\t\t\t\tdb = log10f((float)abs(m_pDctBuff[i]));\r\n\t\t\t\t\t\tif (db > LOG_SAMPLE_RANGE - 4)\r\n\t\t\t\t\t\t\tv = (int)((log10f((float)(abs(m_pDctBuff[i]))) - (LOG_SAMPLE_RANGE - 4)) * m_oPaintRect.bottom / 4);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (v > m_oPaintRect.bottom)\r\n\t\t\t\t\tv = m_oPaintRect.bottom;\r\n\t\t\t\tm_pPaintBoard->DrawLine(l, m_oPaintRect.bottom - v, l, m_oPaintRect.bottom);\r\n\r\n\t\t\t\tswitch (m_nDctState)\r\n\t\t\t\t{\r\n\t\t\t\tcase DCT_LINEAR_FLOAT:\r\n\t\t\t\tcase DCT_LOG10_FLOAT:\r\n\t\t\t\t\tfd = (int)(0.005f * m_pFloatClear[i] * m_pFloatClear[i] * m_pFloatClear[i]);\r\n\r\n\t\t\t\t\tif (m_pFloatLine[i] - fd < v)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tm_pFloatLine[i] = v;\r\n\t\t\t\t\t\tm_pFloatClear[i] = 0;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse if (1 < m_pFloatLine[i] - fd)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tm_pPaintBoard->SetColor(m_nFloatColor);\r\n\t\t\t\t\t\tfd = m_oPaintRect.bottom - (m_pFloatLine[i] - fd);\r\n\t\t\t\t\t\tm_pPaintBoard->DrawLine(l, fd, l, fd + 2);\r\n\t\t\t\t\t\t++m_pFloatClear[i];\r\n\t\t\t\t\t\tm_pPaintBoard->SetColor(m_nFreqAnaColor);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\r\n//\t\tif (!bState && m_nRecvThreshold <= abs(m_pDctBuff[i]))\r\n//\t\t\tif (m_nRecvFreqStart <= nFreq && nFreq <= m_nRecvFreqEnd)\r\n//\t\t\t\tbState = TRUE;\r\n\t} // end of for (i = 0; i < m_nAnalyzeSamples; ++i)\r\n\r\n\tRECT r = m_oPaintRect;\r\n\tr.left += 2;\r\n\tr.top += 2;\r\n\tr.right = r.left + 32;\r\n\tr.bottom = r.top + 12;\r\n\t\r\n\tswitch(m_nWaveState)\r\n\t{\r\n\tcase WAVE_INVISIBLE:\r\n\t\tm_pPaintBoard->SetColor(m_nDisabledColor);\r\n\t\tm_pPaintBoard->DrawText(&r, \"W\", DT_LEFT); break;\r\n\tcase WAVE_ORIGINAL:\r\n\t\tm_pPaintBoard->SetColor(m_nEnabledColor);\r\n\t\tm_pPaintBoard->DrawText(&r, \"W\", DT_LEFT); break;\r\n\tdefault:\r\n\t\tchar szBuff[16];\r\n\t\tm_pPaintBoard->SetColor(m_nEnabledColor);\r\n\t\tsprintf(szBuff, \"W +%ddB\", 6 * (m_nWaveState - WAVE_ORIGINAL));\r\n\t\tm_pPaintBoard->DrawText(&r, szBuff, DT_LEFT); break;\r\n\t}\r\n\r\n\tOffsetRect(&r, 100, 0);\r\n\r\n\tswitch(m_nDctState)\r\n\t{\r\n\tcase DCT_INVISIBLE:\r\n\tcase DCT_LOG10:\r\n\tcase DCT_LINEAR:\r\n\t\tm_pPaintBoard->SetColor(m_nDisabledColor);\r\n\t\tm_pPaintBoard->DrawText(&r, \"~~~\", DT_LEFT); break;\r\n\tcase DCT_LOG10_FLOAT:\r\n\tcase DCT_LINEAR_FLOAT:\r\n\t\tm_pPaintBoard->SetColor(m_nEnabledColor);\r\n\t\tm_pPaintBoard->DrawText(&r, \"~~~\", DT_LEFT); break;\r\n\t}\r\n\r\n\tOffsetRect(&r, 32, 0);\r\n\r\n\tswitch(m_nDctState)\r\n\t{\r\n\tcase DCT_INVISIBLE:\r\n\t\tm_pPaintBoard->SetColor(m_nDisabledColor);\r\n\t\tm_pPaintBoard->DrawText(&r, \"LOG\", DT_LEFT);\r\n\t\tOffsetRect(&r, 32, 0);\r\n\t\tm_pPaintBoard->DrawText(&r, \"LINEAR\", DT_LEFT); break;\r\n\tcase DCT_LOG10_FLOAT:\r\n\tcase DCT_LOG10:\r\n\t\tm_pPaintBoard->SetColor(m_nEnabledColor);\r\n\t\tm_pPaintBoard->DrawText(&r, \"LOG\", DT_LEFT);\r\n\t\tOffsetRect(&r, 32, 0);\r\n\t\tm_pPaintBoard->SetColor(m_nDisabledColor);\r\n\t\tm_pPaintBoard->DrawText(&r, \"LINEAR\", DT_LEFT); break;\r\n\tcase DCT_LINEAR_FLOAT:\r\n\tcase DCT_LINEAR:\r\n\t\tm_pPaintBoard->SetColor(m_nDisabledColor);\r\n\t\tm_pPaintBoard->DrawText(&r, \"LOG\", DT_LEFT);\r\n\t\tOffsetRect(&r, 32, 0);\r\n\t\tm_pPaintBoard->SetColor(m_nEnabledColor);\r\n\t\tm_pPaintBoard->DrawText(&r, \"LINEAR\", DT_LEFT); break;\r\n\t}\r\n\r\n\t//r = m_oPaintRect;\r\n\t//OffsetRect(&r, m_oRect.left, m_oRect.top);\r\n\t//m_pParent->Invalidate(&r);\r\n\tm_pParent->Invalidate(&m_oRect);\r\n\r\n//\tif (NULL != m_pCwEventListener)\r\n//\t\tm_pCwEventListener->OnCwEvent(bState);\r\n\r\n\treturn TRUE;\r\n}\r\n\r\nDWORD CLaWaveCapture::GetSyncPos(short int* pBuff, DWORD nBuffSize)\r\n{\r\n\t//synchronize the wave\r\n\tint nStep = 1;\r\n\tDWORD nSyncStart;\r\n\tfor (nSyncStart = 0; nSyncStart < nBuffSize - 1 && 0 < nStep; ++nSyncStart)\r\n\t{\r\n\t\tswitch(nStep)\r\n\t\t{\r\n\t\t\tcase 1:\r\n\t\t\t\tif (pBuff[nSyncStart] < pBuff[nSyncStart + 1])\r\n\t\t\t\t\tnStep = 2;\r\n\t\t\t\tbreak;\r\n\t\t\tcase 2:\r\n\t\t\t\tif (pBuff[nSyncStart] >= 0 && pBuff[nSyncStart] > pBuff[nSyncStart + 1])\r\n\t\t\t\t\tnStep = 0;\r\n\t\t\t/* for sin wave\r\n\t\t\tcase 1: // look for negative\r\n\t\t\t\tif (m_vWavBuff[nSyncStart] < 0)\r\n\t\t\t\t\tnStep = 2;\r\n\t\t\t\tbreak;\r\n\t\t\tcase 2: // through the X axis\r\n\t\t\t\tif (m_vWavBuff[nSyncStart] >= 0)\r\n\t\t\t\t\tnStep = 0;\r\n\t\t\t\tbreak;\r\n\t\t\t*/\r\n\t\t}\r\n\t}\r\n\r\n\treturn nSyncStart;\r\n}\r\n\r\nBOOL CLaWaveCapture::OnMouseKeyDown(void* owner, MouseKeyType nMkt, int x, int y)\r\n{\r\n\treturn FALSE;\r\n}\r\n\r\nBOOL CLaWaveCapture::OnMouseKeyUp(void* owner, MouseKeyType nMkt, int x, int y)\r\n{\r\n\tswitch(nMkt)\r\n\t{\r\n\t\tcase LBUTTON:\r\n\t\t{\r\n\t\t\tif (WAVE_GAIN_X32 < ++m_nWaveState)\r\n\t\t\t\tm_nWaveState = 0;\r\n\r\n\t\t\tm_nWaveStateTip = 50;\r\n\t\t\treturn TRUE;\r\n\t\t}\r\n\t\tcase RBUTTON:\r\n\t\t{\r\n\t\t\tif (DCT_LINEAR < ++m_nDctState)\r\n\t\t\t\tm_nDctState = 0;\r\n\r\n\t\t\tm_nDctStateTip = 50;\r\n\t\t\tm_bRulerInvalid = TRUE;\r\n\t\t\treturn TRUE;\r\n\t\t}\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nvoid CLaWaveCapture::SetBackgroundColor(int nColor)\r\n{\r\n\tm_nBgColor = nColor;\r\n}\r\n\r\nvoid CLaWaveCapture::SetWaveColor(int nColor)\r\n{\r\n\tm_nWaveColor = nColor;\r\n}\r\n\r\nvoid CLaWaveCapture::SetFloatColor(int nColor)\r\n{\r\n\tm_nFloatColor = nColor;\r\n}\r\n\r\nvoid CLaWaveCapture::SetFreqAnaColor(int nColor)\r\n{\r\n\tm_nFreqAnaColor = nColor;\r\n}\r\n\r\nvoid CLaWaveCapture::InitTestBuffer()\r\n{\r\n\tREAL f = 1000.0f;\r\n\tREAL w = 1.0f / f;\r\n\tREAL d = 1.0f / 44100.0f;\r\n\tint nTimes;\r\n\tfor (nTimes = 100; nTimes <= 1000; ++nTimes)\r\n\t{\r\n\t\tREAL rRemScale = fmod(w * nTimes, d) / w;\r\n\r\n\t\tif (rRemScale < 0.001l || rRemScale > 0.998l)\r\n\t\t\tbreak;\r\n\t}\r\n\r\n\tREAL s = nTimes * w;\r\n\tm_nTestBuffLen = s * 44100;\r\n\tREAL DW = 2 * PI / m_oFormat.nSamplesPerSec;\r\n\tm_pTestBuff = new short int[m_nTestBuffLen];\r\n\r\n\tfor (DWORD i = 0; i < m_nTestBuffLen; ++i)\r\n\t{\r\n\t\tREAL v = sin(DW * i * f * 3) * 0.3 + sin(DW * i * f * 2) * 0.4 + sin(DW * i * f) * 0.5;\t// -1.0 ~ +1.0\r\n\t\tm_pTestBuff[i] = (short int)(v * 32767);\r\n\t}\r\n}"
  },
  {
    "path": "src/LaWaveCapture.h",
    "content": "#pragma once\r\n\r\n#include \"EventManagerWin32.h\"\r\n#include \"FFT.h\"\r\n#include \"dsound.h\"\r\n\r\n//log(32768)\r\n//#define LOG_SAMPLE_RANGE\t4.51545\t\r\n#define LOG_SAMPLE_RANGE\t4.51545f\r\n\r\n// CLaWaveCapture.m_nWaveState values\r\n#define WAVE_INVISIBLE\t\t0\r\n#define WAVE_ORIGINAL\t\t1\r\n#define WAVE_GAIN_X2\t\t2\r\n#define WAVE_GAIN_X4\t\t3\r\n#define WAVE_GAIN_X8\t\t4\r\n#define WAVE_GAIN_X16\t\t5\r\n#define WAVE_GAIN_X32\t\t6\r\n\r\n// CLaWaveCapture.m_nDctState values\r\n#define DCT_INVISIBLE\t\t0\r\n#define DCT_LOG10_FLOAT\t\t1\r\n#define DCT_LOG10\t\t\t2\r\n#define DCT_LINEAR_FLOAT\t3\r\n#define DCT_LINEAR\t\t\t4\r\n\r\nclass ICwEventListener\r\n{\r\npublic:\r\n\tvirtual void OnCwEvent(BOOL bCwDown) = 0;\r\n};\r\n\r\nclass CLaWaveCapture\r\n\t: public IPaintEventControl\r\n\t, public IMouseKeyEventControl\r\n\t, public IFilterDFT<short int, float>\r\n{\r\npublic:\r\n\tCLaWaveCapture(IPaintableParent* pParent, const RECT* pRect, int nSamplePerSec, int nAnalyzeSample, IFilterDFT<short int, float>* pNextFilter, ICwEventListener* pCwEventListener = NULL);\r\n\t~CLaWaveCapture(void);\r\n\r\n\tvirtual BOOL IsRelated(int x, int y);\r\n\tvirtual void GetRect(RECT* r);\r\n\tvirtual BOOL OnPaint(void* owner, CGraphics* g, const RECT* pRect);\r\n\r\n\tvirtual BOOL Initialize();\r\n\tvirtual BOOL Refresh();\r\n\r\n\tvirtual void SetThresholdLevel(double rThresholdLevel);\r\n\tvirtual void SetFreqRange(int nLowFreq, int nHighFreq);\r\n\r\n\tvirtual BOOL OnMouseKeyDown(void* owner, MouseKeyType nMkt, int x, int y);\r\n\tvirtual BOOL OnMouseKeyUp(void* owner, MouseKeyType nMkt, int x, int y);\r\n\tvirtual BOOL OnClick(void* owner) { return FALSE; };\r\n\r\n\tvirtual short int OnEncodeFilter(float val, int i);\r\n\tvirtual short int OnDecodeFilter(float val, int i);\r\n\r\n\tvoid SetBackgroundColor(int nColor);\r\n\tvoid SetWaveColor(int nColor);\r\n\tvoid SetFloatColor(int nColor);\r\n\tvoid SetFreqAnaColor(int nColor);\r\n\r\n\tBOOL GetFrazeState() { return m_bFraze; };\r\n\tvoid SetFrazeState(BOOL bFraze) { m_bFraze = bFraze; }\r\n\r\nprivate:\r\n\tint AnalyzeData();\r\n\tDWORD GetSyncPos(short int* pBuff, DWORD nBuffSize);\r\n\r\n\tvoid DrawRuler();\r\n\tvoid DrawBorder();\r\n\tvoid DrawGrid();\r\n\r\n\tIPaintableParent*\t\tm_pParent;\r\n\tCFont*\t\tm_pFont;\r\n\tRECT\t\tm_oRect;\t// by parent\r\n\tRECT\t\tm_oPaintRect;\t// by self\r\n\tRECT\t\tm_oRulerRectH;\t// by self\r\n\tRECT\t\tm_oRulerRectV;\t// by self\r\n\tint\t\tm_nRulerWidthH;\r\n\tint\t\tm_nRulerWidthV;\r\n\tint\t\tm_nRulerGridsV;\r\n\tint\t\tm_nRulerDbMax;\r\n\tCGraphics*\tm_pPaintBoard;\r\n\r\n\tIDirectSoundCapture*\t\tm_pDsCap;\r\n\tIDirectSoundCaptureBuffer*\tm_pDsCapBuff;\r\n\r\n\tWAVEFORMATEX\t\tm_oFormat;\r\n\tDSCBUFFERDESC\t\tm_oCaptureBufferDesc;\r\n\tint\t\tm_nNextPeriodStartPos;\r\n\r\n\tshort int*\tm_pWavBuff; //[m_nAnalyzeSamples * 2];\r\n\tshort int*\tm_pDctBuff; //[m_nAnalyzeSamples];\r\n\tshort int*\tm_pFreqRuler; //[m_oRulerWidth];\r\n\tshort int*\tm_pFloatLine; //[m_nAnalyzeSamples];\r\n\tshort int*  m_pFloatClear;\r\n\r\n//\tTCosDFT<short int, float>*\t\tm_pFft;\r\n\tTFastFT<short int, float>*\t\tm_pFft;\r\n\tIFilterDFT<short int, float>*\tm_pNextFilter;\r\n\r\n\tICwEventListener* m_pCwEventListener;\r\n\tDWORD\t\tm_nAnalyzeSamples;\r\n\tint\t\t\tm_nRecvThreshold;\r\n\tint\t\t\tm_nRecvFreqStart;\r\n\tint\t\t\tm_nRecvFreqEnd;\r\n\r\n\tBOOL\t\tm_nCwState;\r\n\r\n\tshort int\tm_nWaveState;\r\n\tshort int\tm_nDctState;\r\n\tint\t\t\tm_nWaveStateTip;\r\n\tint\t\t\tm_nDctStateTip;\r\n\r\n\tint\t\t\tm_nBorderWidth;\r\n\tint\t\t\tm_nRularH;\r\n\tint\t\t\tm_nRularV;\r\n\r\n\tint\t\t\tm_nBgColor;\r\n\tint\t\t\tm_nWaveColor;\r\n\tint\t\t\tm_nFloatColor;\r\n\tint\t\t\tm_nFreqAnaColor;\r\n\tint\t\t\tm_nRulerColorH;\r\n\tint\t\t\tm_nRulerColorV;\r\n\tint\t\t\tm_nGridColorH;\r\n\tint\t\t\tm_nGridColorV;\r\n\tint\t\t\tm_nEnabledColor;\r\n\tint\t\t\tm_nDisabledColor;\r\n\r\n\tBOOL\t\tm_bRulerInvalid;\r\n\tBOOL\t\tm_bFraze;\r\n\r\n\r\n\t/* for test only */\r\n\tint\t\t\tm_nTestBuffLen;\r\n\tint\t\t\tm_nTestIndex;\r\n\tshort int*\tm_pTestBuff;\r\n\tvoid\t\tInitTestBuffer();\r\n\tint\t\t\tm_nTestInt;\r\n};\r\n"
  },
  {
    "path": "src/LaWaveFile.cpp",
    "content": "#include \"StdAfx.h\"\r\n#include \"stdio.h\"\r\n#include \"math.h\"\r\n#include \"assert.h\"\r\n#include \"LaWaveFile.h\"\r\n\r\n#define RESOLVEDWORD(a, b, c, d) (((DWORD)(a)) | (((DWORD)(b)) << 8) | (((DWORD)(c)) << 16) | (((DWORD)(d)) << 24))\r\n#define PI\t\t\t\t3.1415926f\r\n\r\nCWaveFile::CWaveFile(const char* pPathname, WORD nChannels, DWORD nSamplesPerSec, WORD  wBitsPerSample, float rSampleBuffSec)\r\n{\r\n\tm_pDestFile = fopen(pPathname, \"wb\");\r\n\tmemset(&m_oWaveFileInfo, 0, sizeof(m_oWaveFileInfo));\r\n\tm_oWaveFileInfo.nRiffFlag = RESOLVEDWORD('R', 'I', 'F', 'F');\r\n\tm_oWaveFileInfo.nCbSize = \r\n\t\tsizeof(m_oWaveFileInfo) - sizeof(m_oWaveFileInfo.nRiffFlag) - sizeof(m_oWaveFileInfo.nCbSize);\r\n\tm_oWaveFileInfo.oWaveHeader.nWaveFlag = RESOLVEDWORD('W', 'A', 'V', 'E');\r\n\tm_oWaveFileInfo.oWaveHeader.nFmtFlag = RESOLVEDWORD('f', 'm', 't', ' ');\r\n\tm_oWaveFileInfo.oWaveHeader.nCbSize = sizeof(m_oWaveFileInfo.oWaveHeader.oWaveInfo);\r\n\tm_oWaveFileInfo.oWaveHeader.oWaveInfo.nBlank = 1;\r\n\tm_oWaveFileInfo.oWaveHeader.oWaveInfo.nChannels = nChannels;\r\n\tm_oWaveFileInfo.oWaveHeader.oWaveInfo.nSamplesPerSec = nSamplesPerSec;\r\n\tm_oWaveFileInfo.oWaveHeader.oWaveInfo.nAvgBytesPerSec = \r\n\t\tnSamplesPerSec * nChannels * wBitsPerSample / 8;\r\n\tm_oWaveFileInfo.oWaveHeader.oWaveInfo.nBlockAlign = nChannels * wBitsPerSample / 8;\r\n\tm_oWaveFileInfo.oWaveHeader.oWaveInfo.wBitsPerSample = wBitsPerSample;\r\n\tm_oWaveFileInfo.oWaveHeader.nDataFlag = RESOLVEDWORD('d', 'a', 't', 'a');\r\n\tm_oWaveFileInfo.oWaveHeader.nDataLength = 0;\r\n\r\n\tfwrite(&m_oWaveFileInfo, sizeof(m_oWaveFileInfo), 1, m_pDestFile);\r\n\r\n\tm_rSampleBuffSec = rSampleBuffSec;\r\n\r\n\tm_nWavBuffLen = (int)(rSampleBuffSec * m_oWaveFileInfo.oWaveHeader.oWaveInfo.nAvgBytesPerSec);\r\n\tm_pWavBuff = new char[m_nWavBuffLen];\r\n\tm_bModified = TRUE;\r\n}\r\n\r\nCWaveFile::~CWaveFile()\r\n{\r\n\tdelete[] m_pWavBuff;\r\n\tfclose(m_pDestFile);\r\n}\r\n\r\nvoid CWaveFile::SetFreq(float rFreq)\r\n{\r\n\tm_rFreq = rFreq;\r\n\tm_bModified = TRUE;\r\n}\r\n\r\nvoid CWaveFile::SetVolumn(float rVol)\r\n{\r\n\tm_rVol = rVol;\r\n\tm_bModified = TRUE;\r\n}\r\n\r\nint CWaveFile::AppendRaw(const char* pBuff, DWORD nLen, int nCount)\r\n{\r\n\tassert(0 == (nLen * nCount) % 2);\r\n\tDWORD nBlockSize = nLen * nCount;\r\n\r\n\tm_oWaveFileInfo.nCbSize += nBlockSize;\r\n\tm_oWaveFileInfo.oWaveHeader.nDataLength += nBlockSize;\r\n\r\n\tfseek(m_pDestFile, 0, SEEK_END);\r\n\tfor (int i = 0; i < nCount; ++i)\r\n\t\tfwrite(pBuff, 1, nLen, m_pDestFile);\r\n\r\n\tfseek(m_pDestFile, 0, SEEK_SET);\r\n\tfwrite(&m_oWaveFileInfo, sizeof(m_oWaveFileInfo), 1, m_pDestFile);\r\n\treturn nBlockSize;\r\n}\r\n\r\nint CWaveFile::AppendBlank(float rSec)\r\n{\r\n\tDWORD nBytes = (DWORD)(rSec * m_oWaveFileInfo.oWaveHeader.oWaveInfo.nAvgBytesPerSec);\r\n\tif (0 != nBytes % 2)\r\n\t\t++nBytes;\r\n\tchar c = '\\0';\r\n\treturn AppendRaw(&c, 1, nBytes);\r\n}\r\n\r\nint CWaveFile::Append(float rSec)\r\n{\r\n\tif (m_bModified)\r\n\t{\r\n\t\tInitWavBuff();\r\n\t}\r\n\t\r\n\tDWORD nBytes = (DWORD)(rSec * m_oWaveFileInfo.oWaveHeader.oWaveInfo.nAvgBytesPerSec);\r\n\tif (0 != nBytes % 2)\r\n\t\t++nBytes;\r\n\r\n\tassert(nBytes <= m_nWavBuffLen);\r\n\treturn AppendRaw(m_pWavBuff, nBytes, 1);\r\n}\r\n\r\nvoid CWaveFile::InitWavBuff()\r\n{\r\n\tfloat dt = 1.0f / m_oWaveFileInfo.oWaveHeader.oWaveInfo.nSamplesPerSec;\r\n\tDWORD nBytesPerSample = m_oWaveFileInfo.oWaveHeader.oWaveInfo.wBitsPerSample / 8;\r\n\r\n\tfor (DWORD i = 0; i < m_nWavBuffLen / nBytesPerSample; ++i)\r\n\t{\r\n\t\tfloat v = sin(2 * PI * dt * i * m_rFreq) * m_rVol;\t// -1.0 ~ +1.0\r\n\r\n\t\tfor (DWORD j = 0; j < m_oWaveFileInfo.oWaveHeader.oWaveInfo.nChannels; ++j)\r\n\t\t{\r\n\t\t\tif (16 == m_oWaveFileInfo.oWaveHeader.oWaveInfo.wBitsPerSample)\r\n\t\t\t{\r\n\t\t\t\t*(((short int *)m_pWavBuff) + i * m_oWaveFileInfo.oWaveHeader.oWaveInfo.nChannels + j) = (short int)(v * 32767);\r\n\t\t\t}\r\n\t\t\telse if (8 == m_oWaveFileInfo.oWaveHeader.oWaveInfo.wBitsPerSample)\r\n\t\t\t{\r\n\t\t\t\t*(((char *)m_pWavBuff) + i * m_oWaveFileInfo.oWaveHeader.oWaveInfo.nChannels + j) = (char)(v * 255);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tassert(0);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tm_bModified = FALSE;\r\n}\r\n\r\n"
  },
  {
    "path": "src/LaWaveFile.h",
    "content": "\r\ntypedef struct\r\n{\r\n\tDWORD\tnRiffFlag;\t\t//'RIFF'\r\n\tDWORD\tnCbSize;\r\n\tstruct\r\n\t{\r\n\t\tDWORD nWaveFlag;\t//'WAVE'\r\n\t\tDWORD nFmtFlag;\t\t//'fmt '\r\n\t\tDWORD nCbSize;\r\n\t\tstruct\r\n\t\t{\r\n\t\t\tWORD nBlank;\r\n\t\t\tWORD nChannels;\r\n\t\t\tDWORD nSamplesPerSec; \r\n\t\t\tDWORD nAvgBytesPerSec; \r\n\t\t\tWORD  nBlockAlign; \r\n\t\t\tWORD  wBitsPerSample;\r\n\t\t} oWaveInfo;\r\n\t\tDWORD nDataFlag;\t//'data'\r\n\t\tDWORD nDataLength;\r\n\t} oWaveHeader;\r\n} LAAUDIOFILEHEADER;\r\n\r\nclass CWaveFile\r\n{\r\npublic:\r\n\tCWaveFile(const char* pPathname, WORD nChannels, DWORD nSamplesPerSec, WORD  wBitsPerSample, float rSampleBuffSec);\r\n\t~CWaveFile();\r\n\tint AppendRaw(const char* pBuff, DWORD nLen, int nCount);\r\n\tvoid SetFreq(float rFreq);\r\n\tvoid SetVolumn(float rVol);\r\n\tint Append(float rSec);\r\n\tint AppendBlank(float rSec);\r\n\r\nprivate:\r\n\tvoid InitWavBuff();\r\n\tFILE* m_pDestFile;\r\n\tLAAUDIOFILEHEADER m_oWaveFileInfo;\r\n\tchar*\tm_pWavBuff;\r\n\tDWORD\tm_nWavBuffLen;\r\n\tBOOL\tm_bModified;\r\n\r\n\tfloat\tm_rSampleBuffSec;\r\n\tfloat\tm_rFreq;\r\n\tfloat\tm_rVol;\r\n};\r\n"
  },
  {
    "path": "src/Lakey.h",
    "content": "#pragma once\r\n\r\n#include \"resource.h\"\r\n"
  },
  {
    "path": "src/Lakey.rc",
    "content": "// Microsoft Visual C++ generated resource script.\r\n//\r\n#include \"resource.h\"\r\n\r\n#define APSTUDIO_READONLY_SYMBOLS\r\n/////////////////////////////////////////////////////////////////////////////\r\n//\r\n// Generated from the TEXTINCLUDE 2 resource.\r\n//\r\n#define APSTUDIO_HIDDEN_SYMBOLS\r\n#include \"windows.h\"\r\n#undef APSTUDIO_HIDDEN_SYMBOLS\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n#undef APSTUDIO_READONLY_SYMBOLS\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n// (壬й) resources\r\n\r\n#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)\r\nLANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED\r\n#pragma code_page(936)\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n//\r\n// Icon\r\n//\r\n\r\n// Icon with lowest ID value placed first to ensure application icon\r\n// remains consistent on all systems.\r\nIDI_LAKEY               ICON                    \"Lakey.ico\"\r\n\r\nIDI_SMALL               ICON                    \"small.ico\"\r\n\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n//\r\n// Menu\r\n//\r\n\r\nIDC_LAKEY MENU\r\nBEGIN\r\n    POPUP \"ļ(&F)\"\r\n    BEGIN\r\n        MENUITEM \"˳(&X)\",                      IDM_EXIT\r\n    END\r\n    POPUP \"(&T)\"\r\n    BEGIN\r\n        MENUITEM \"CWƵļ(&W)\",                IDM_PROMPTWAVE\r\n        MENUITEM SEPARATOR\r\n        MENUITEM \"Kochѵ\\tCtrl+K\",             IDM_KOCHSTART\r\n        MENUITEM \"KochƵļ(&G)\",              IDM_KOCHWAVE\r\n        MENUITEM SEPARATOR\r\n        MENUITEM \"ѵ(&T)\",                    IDM_SENDTRAINING\r\n        MENUITEM SEPARATOR\r\n        MENUITEM \"(&S)\",                      IDM_SETTINGS\r\n    END\r\n    POPUP \"(&H)\"\r\n    BEGIN\r\n        MENUITEM \"(&A)...\",                   IDM_ABOUT\r\n    END\r\nEND\r\n\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n//\r\n// Accelerator\r\n//\r\n\r\nIDC_LAKEY ACCELERATORS\r\nBEGIN\r\n    \"/\",            IDM_ABOUT,              ASCII,  ALT, NOINVERT\r\n    \"?\",            IDM_ABOUT,              ASCII,  ALT, NOINVERT\r\n    \"K\",            IDM_KOCHSTART,          VIRTKEY, CONTROL, NOINVERT\r\n    VK_ESCAPE,      IDM_KOCHSTOP,           VIRTKEY, NOINVERT\r\nEND\r\n\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n//\r\n// Dialog\r\n//\r\n\r\nIDD_ABOUTBOX DIALOGEX 22, 17, 215, 73\r\nSTYLE DS_SETFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU\r\nCAPTION \"Lakey\"\r\nFONT 9, \"Arial\", 400, 0, 0x0\r\nBEGIN\r\n    CONTROL         IDB_BITMAP1,IDC_MYICON,\"Static\",SS_BITMAP | SS_REALSIZEIMAGE | WS_BORDER,5,7,62,51\r\n    LTEXT           \"Lakey Version 2.2.0020 (Paper)\",IDC_STATIC,76,6,129,8,SS_NOPREFIX\r\n    LTEXT           \"(C) 2006-2020\",IDC_STATIC,76,16,129,8\r\n    LTEXT           \"DE BG1VLZ, idirect3d@hotmail.com, VY\",IDC_STATIC,76,38,132,8\r\n    LTEXT           \"-.-. --.- -.-. --.- -.-. --.- -.-. --.- -.-. --.- -.-. --.- -.-. --.- -.-. --.- -.-. --.- -.-. --.-\",IDC_STATIC,6,63,203,8\r\n    LTEXT           \"73 ^_^\",IDC_STATIC,76,49,132,8\r\nEND\r\n\r\nIDD_PROMPTBOX DIALOGEX 22, 17, 215, 73\r\nSTYLE DS_SETFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU\r\nCAPTION \"\"\r\nFONT 9, \"Arial\", 400, 0, 0x0\r\nBEGIN\r\n    LTEXT           \": \",IDC_PROMPTTEXT,7,10,200,8\r\n    EDITTEXT        IDC_INPUTSTR,7,33,200,12,ES_UPPERCASE | ES_AUTOHSCROLL | ES_WANTRETURN\r\n    PUSHBUTTON      \"ύ\",IDOK,155,56,47,10\r\n    PUSHBUTTON      \"ȡ\",IDCANCEL,100,56,47,10\r\nEND\r\n\r\nIDD_SETTINGS DIALOGEX 22, 17, 254, 194\r\nSTYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_CAPTION | WS_SYSMENU\r\nEXSTYLE WS_EX_TOOLWINDOW\r\nCAPTION \"Settings\"\r\nFONT 9, \"MS Shell Dlg\", 400, 0, 0x0\r\nBEGIN\r\n    CONTROL         \"\",IDC_SETTINGSTAB,\"SysTabControl32\",0x0,2,3,249,170\r\n    PUSHBUTTON      \"ȷ\",IDC_ACCEPT,190,178,47,12\r\n    PUSHBUTTON      \"ȡ\",IDCANCEL,135,178,47,12\r\nEND\r\n\r\nIDD_COPYPAD DIALOGEX 0, 0, 343, 199\r\nSTYLE DS_SETFONT | WS_POPUP | WS_CAPTION | WS_SYSMENU\r\nEXSTYLE WS_EX_TOPMOST | WS_EX_TOOLWINDOW\r\nCAPTION \"\"\r\nFONT 8, \"Courier New\", 400, 0, 0x0\r\nBEGIN\r\n    CONTROL         \"\",IDC_COPYTEXT,\"RichEdit20A\",ES_MULTILINE | ES_NUMBER | WS_BORDER | WS_VSCROLL | WS_TABSTOP,0,0,342,175\r\n    DEFPUSHBUTTON   \"\",IDC_ACCEPT,277,181,55,12\r\n    LTEXT           \"00:00:00\",IDC_ELAPSETIME,9,184,37,10\r\n    RTEXT           \"0\",IDC_COPIED,59,184,37,10\r\n    RTEXT           \"0\",IDC_INCORRECT,109,184,37,10\r\n    RTEXT           \"0%\",IDC_CORRECTPERC,159,184,37,10\r\n    GROUPBOX        \"ʱ\",IDC_STATIC,3,176,47,21\r\n    GROUPBOX        \"¼\",IDC_STATIC,53,176,47,21\r\n    GROUPBOX        \"\",IDC_STATIC,103,176,47,21\r\n    GROUPBOX        \"ȷ\",IDC_STATIC,153,176,47,21\r\nEND\r\n\r\nIDD_TEST DIALOGEX 0, 0, 348, 148\r\nSTYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU\r\nCAPTION \"Dialog\"\r\nFONT 8, \"MS Shell Dlg\", 400, 0, 0x1\r\nBEGIN\r\n    DEFPUSHBUTTON   \"ȷ\",IDOK,291,7,50,14\r\n    PUSHBUTTON      \"ȡ\",IDCANCEL,291,24,50,14\r\n    CONTROL         \"\",IDC_RICHEDIT21,\"RichEdit20A\",ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP,7,7,180,134\r\nEND\r\n\r\nIDD_GENERAL DIALOGEX 0, 0, 284, 163\r\nSTYLE DS_SETFONT | DS_SETFOREGROUND | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE\r\nFONT 8, \"MS Shell Dlg\", 400, 0, 0x1\r\nBEGIN\r\n    EDITTEXT        IDC_SHORTHIT,42,14,29,14,ES_AUTOHSCROLL | ES_NUMBER\r\n    EDITTEXT        IDC_HITDELAY,137,14,29,14,ES_AUTOHSCROLL | ES_NUMBER\r\n    EDITTEXT        IDC_SPEED,218,14,29,14,ES_AUTOHSCROLL | ES_NUMBER\r\n    EDITTEXT        IDC_LONGHIT,42,32,29,14,ES_AUTOHSCROLL | ES_NUMBER\r\n    EDITTEXT        IDC_LETTERDELAY,137,32,29,14,ES_AUTOHSCROLL | ES_NUMBER\r\n    PUSHBUTTON      \"\",IDC_CALCSPEED,199,33,77,12\r\n    GROUPBOX        \"CW\",IDC_STATIC,4,2,276,52\r\n    LTEXT           \"\"\"\"\"\",IDC_STATIC,8,17,35,9\r\n    LTEXT           \"(ms)\",IDC_STATIC,76,17,19,9\r\n    LTEXT           \"\"\"\"\"\",IDC_STATIC,8,35,35,9\r\n    LTEXT           \"(ms)\",IDC_STATIC,76,35,19,9\r\n    LTEXT           \"\",IDC_STATIC,103,17,35,9\r\n    LTEXT           \"(ms)\",IDC_STATIC,171,35,19,9\r\n    LTEXT           \"ַ\",IDC_STATIC,103,35,35,9\r\n    LTEXT           \"(ms)\",IDC_STATIC,171,17,19,9\r\n    LTEXT           \"\",IDC_STATIC,199,17,18,9\r\n    LTEXT           \"(wpm)\",IDC_STATIC,252,17,23,9\r\n    LTEXT           \"ͨڡ١¼Ҫļ٣WPMֵɣԶ㡣΢˳١Ĳͨ١ť㵱ǰֵ\",IDC_STATIC,19,70,244,33\r\nEND\r\n\r\nIDD_SEND DIALOGEX 0, 0, 284, 163\r\nSTYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE | WS_SYSMENU\r\nFONT 8, \"MS Shell Dlg\", 400, 0, 0x1\r\nBEGIN\r\n    EDITTEXT        IDC_BEEPFREQ,49,14,53,14,ES_AUTOHSCROLL\r\n    EDITTEXT        IDC_BEEPVOL,49,32,53,14,ES_AUTOHSCROLL\r\n    EDITTEXT        IDC_SENDPERIOD,49,50,53,14,ES_AUTOHSCROLL | ES_NUMBER\r\n    EDITTEXT        IDC_SENDILDELIMIT,184,14,53,14,ES_AUTOHSCROLL | ES_NUMBER\r\n    EDITTEXT        IDC_CW,184,32,53,14,ES_AUTOHSCROLL | ES_WANTRETURN | ES_NUMBER\r\n    EDITTEXT        IDC_WORDDELAY,184,50,53,14,ES_AUTOHSCROLL | ES_NUMBER\r\n    LTEXT           \"趨ǺͷصĲ\",IDC_STATIC,26,78,237,33\r\n    GROUPBOX        \"\",IDC_STATIC,4,2,276,68\r\n    LTEXT           \"\",IDC_STATIC,10,17,20,9\r\n    LTEXT           \"(Hz)\",IDC_STATIC,107,17,17,9\r\n    LTEXT           \"\",IDC_STATIC,10,35,20,9\r\n    LTEXT           \"0~1.0\",IDC_STATIC,106,35,22,9\r\n    LTEXT           \"\",IDC_STATIC,9,53,35,9\r\n    LTEXT           \"(ms)\",IDC_STATIC,107,53,19,9\r\n    LTEXT           \"ֹͣ\",IDC_STATIC,144,16,35,9\r\n    LTEXT           \"(ms)\",IDC_STATIC,242,16,19,9\r\n    LTEXT           \"CW\",IDC_STATIC,144,35,35,9\r\n    LTEXT           \"VK code\",IDC_STATIC,242,35,31,9\r\n    LTEXT           \"ոӳ\",IDC_STATIC,144,53,35,9\r\n    LTEXT           \"(ms)\",IDC_STATIC,242,53,19,9\r\nEND\r\n\r\nIDD_RECV DIALOGEX 0, 0, 284, 163\r\nSTYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE | WS_SYSMENU\r\nFONT 8, \"MS Shell Dlg\", 400, 0, 0x1\r\nBEGIN\r\n    EDITTEXT        IDC_RECVANALYZESAMPLES,49,14,53,14,ES_AUTOHSCROLL | ES_NUMBER\r\n    EDITTEXT        IDC_RECVPERIOD,49,32,53,14,ES_AUTOHSCROLL | ES_NUMBER\r\n    EDITTEXT        IDC_RECVILDELIMIT,49,50,53,14,ES_AUTOHSCROLL | ES_NUMBER\r\n    EDITTEXT        IDC_RECVTHRESHOLD,184,14,53,14,ES_AUTOHSCROLL\r\n    EDITTEXT        IDC_RECVFREQSTART,184,32,53,14,ES_AUTOHSCROLL | ES_NUMBER\r\n    EDITTEXT        IDC_RECVFREQEND,184,50,53,14,ES_AUTOHSCROLL | ES_NUMBER\r\n    LTEXT           \"趨ǺձصĲ\",IDC_STATIC,26,78,237,33\r\n    GROUPBOX        \"\",IDC_STATIC,4,2,276,69\r\n    LTEXT           \"\",IDC_STATIC,9,17,35,9\r\n    LTEXT           \"()\",IDC_STATIC,107,17,14,9\r\n    LTEXT           \"\",IDC_STATIC,9,35,35,9\r\n    LTEXT           \"(ms)\",IDC_STATIC,107,35,19,9\r\n    LTEXT           \"ֹͣ\",IDC_STATIC,9,53,35,9\r\n    LTEXT           \"(ms)\",IDC_STATIC,107,53,19,9\r\n    LTEXT           \"ֵƽ\",IDC_STATIC,144,17,35,9\r\n    LTEXT           \"0~1.0\",IDC_STATIC,242,17,22,9\r\n    LTEXT           \"ʼƵ\",IDC_STATIC,144,35,35,9\r\n    LTEXT           \"(Hz)\",IDC_STATIC,242,35,17,9\r\n    LTEXT           \"ֹƵ\",IDC_STATIC,144,53,35,9\r\n    LTEXT           \"(Hz)\",IDC_STATIC,242,53,17,9\r\nEND\r\n\r\nIDD_IO DIALOGEX 0, 0, 284, 163\r\nSTYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE | WS_SYSMENU\r\nFONT 8, \"MS Shell Dlg\", 400, 0, 0x1\r\nBEGIN\r\n    CONTROL         \"\",IDC_EXTPORTENABLE,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,10,16,37,9\r\n    EDITTEXT        IDC_EXTPORTADDR,99,14,37,14,ES_UPPERCASE | ES_READONLY\r\n    EDITTEXT        IDC_OPENBYTE,188,14,15,14,ES_UPPERCASE\r\n    EDITTEXT        IDC_CLOSEBYTE,251,14,15,14,ES_UPPERCASE\r\n    LTEXT           \"»̧CWʱLakeyָӲ˿ڵַضݣԱһЩΧ豸\",IDC_STATIC,20,44,244,22\r\n    GROUPBOX        \"˿ڿ\",IDC_STATIC,4,2,276,32\r\n    LTEXT           \"ַ(HEX)\",IDC_STATIC,59,16,37,9\r\n    LTEXT           \"(HEX)\",IDC_STATIC,146,16,37,9\r\n    LTEXT           \"ر(HEX)\",IDC_STATIC,211,16,37,9\r\n    LTEXT           \"ע⣺ȷӲַ趨пܻżһЩӲ²ϵͳ쳣޸ģ\",IDC_STATIC,19,90,244,25,WS_BORDER\r\n    LTEXT           \"(ö˿ڵַοֵ - 278H/378H - 3E8H/3F8H/2F8H)\",IDC_STATIC,25,70,237,16\r\nEND\r\n\r\nIDD_KOCH DIALOGEX 0, 0, 284, 163\r\nSTYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE | WS_SYSMENU\r\nFONT 8, \"MS Shell Dlg\", 400, 0, 0x1\r\nBEGIN\r\n    EDITTEXT        IDC_KOCHCHARS,49,14,223,14,ES_UPPERCASE | ES_AUTOHSCROLL | ES_WANTRETURN\r\n    EDITTEXT        IDC_KOCHWORDLEN,49,32,25,14,ES_AUTOHSCROLL | ES_NUMBER\r\n    LTEXT           \"ڡַKOCHѵҪѵĸѵʱѡȡַеַѵÿšֳȡַһո񡱣һȣͣ١\",IDC_STATIC,22,67,246,35\r\n    GROUPBOX        \"ϰ\",IDC_STATIC,4,2,276,55\r\n    LTEXT           \"ַ\",IDC_STATIC,9,17,31,9\r\n    LTEXT           \"ֳ\",IDC_STATIC,9,35,32,9\r\n    LTEXT           \"Kochַ˳򣩣\\n\\nK M R S U A P T L O W I . N J E F 0 Y , V G 5 / Q 9 Z H 3 8 B ? 4 2 7 C 1 D 6 X <BT> <SK> <AR>\",IDC_STATIC,22,108,245,36\r\nEND\r\n\r\nIDD_NETWORK DIALOGEX 0, 0, 284, 163\r\nSTYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE\r\nEXSTYLE WS_EX_TRANSPARENT\r\nFONT 8, \"MS Shell Dlg\", 400, 0, 0x1\r\nBEGIN\r\n    CONTROL         \"\",IDC_NWENABLED,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,227,15,48,10\r\n    EDITTEXT        IDC_HOSTNAME,51,44,79,14,ES_AUTOHSCROLL\r\n    PUSHBUTTON      \"\",IDC_HOSTADD,197,44,35,13,BS_FLAT\r\n    PUSHBUTTON      \"ɾ\",IDC_HOSTDEL,238,44,35,13\r\n    CONTROL         \"\",IDC_HOSTLIST,\"SysListView32\",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_EDITLABELS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,10,62,263,62\r\n    EDITTEXT        IDC_LOCALPORT,51,14,30,14,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER\r\n    EDITTEXT        IDC_HOSTPORT,158,44,29,14,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER\r\n    GROUPBOX        \"\",IDC_STATIC,4,2,276,127\r\n    LTEXT           \"ض˿\",IDC_STATIC,11,17,32,9\r\n    LTEXT           \"ڽڵпӾַ̬㲥ַȡ\",IDC_STATIC,17,135,243,13\r\n    LTEXT           \"˿\",IDC_STATIC,137,47,21,9\r\n    CONTROL         \"\",IDC_STATIC,\"Static\",SS_ETCHEDHORZ,10,36,265,1\r\n    LTEXT           \" - IP\",IDC_STATIC,11,47,31,9\r\nEND\r\n\r\nIDD_SETTINGS2 DIALOGEX 22, 17, 243, 242\r\nSTYLE DS_SETFONT | WS_CAPTION | WS_SYSMENU\r\nEXSTYLE WS_EX_TOOLWINDOW\r\nCAPTION \"Settings\"\r\nFONT 9, \"Arial\", 400, 0, 0x0\r\nBEGIN\r\n    GROUPBOX        \"\",IDC_STATIC,3,3,117,105\r\n    LTEXT           \"\",IDC_STATIC,7,17,17,8\r\n    EDITTEXT        IDC_BEEPFREQ,41,15,45,12,ES_AUTOHSCROLL\r\n    LTEXT           \"(Hz)\",IDC_STATIC,90,17,15,8\r\n    LTEXT           \"\",IDC_STATIC,7,32,17,8\r\n    EDITTEXT        IDC_BEEPVOL,41,30,45,12,ES_AUTOHSCROLL\r\n    LTEXT           \"0~1.0\",IDC_STATIC,90,32,19,8\r\n    LTEXT           \"\",IDC_STATIC,7,47,30,8\r\n    EDITTEXT        IDC_SENDPERIOD,41,45,45,12,ES_AUTOHSCROLL | ES_NUMBER\r\n    LTEXT           \"(ms)\",IDC_STATIC,91,47,16,8\r\n    LTEXT           \"ֹͣ\",IDC_STATIC,7,62,30,8\r\n    EDITTEXT        IDC_SENDILDELIMIT,41,60,45,12,ES_AUTOHSCROLL | ES_NUMBER\r\n    LTEXT           \"(ms)\",IDC_STATIC,91,62,16,8\r\n    LTEXT           \"CW\",IDC_STATIC,7,77,30,8\r\n    EDITTEXT        IDC_CW,41,75,45,12,ES_AUTOHSCROLL | ES_WANTRETURN | ES_NUMBER\r\n    LTEXT           \"VK code\",IDC_STATIC,91,77,27,8\r\n    LTEXT           \"ոӳ\",IDC_STATIC,7,92,30,8\r\n    EDITTEXT        IDC_WORDDELAY,41,90,45,12,ES_AUTOHSCROLL | ES_NUMBER\r\n    LTEXT           \"(ms)\",IDC_STATIC,91,92,16,8\r\n    GROUPBOX        \"\",IDC_STATIC,125,3,115,105\r\n    LTEXT           \"\",IDC_STATIC,132,17,30,8\r\n    EDITTEXT        IDC_RECVANALYZESAMPLES,166,15,45,12,ES_AUTOHSCROLL | ES_NUMBER\r\n    LTEXT           \"()\",IDC_STATIC,216,17,12,8\r\n    LTEXT           \"\",IDC_STATIC,132,32,30,8\r\n    EDITTEXT        IDC_RECVPERIOD,166,30,45,12,ES_AUTOHSCROLL | ES_NUMBER\r\n    LTEXT           \"(ms)\",IDC_STATIC,216,32,16,8\r\n    LTEXT           \"ֹͣ\",IDC_STATIC,132,47,30,8\r\n    EDITTEXT        IDC_RECVILDELIMIT,166,45,45,12,ES_AUTOHSCROLL | ES_NUMBER\r\n    LTEXT           \"(ms)\",IDC_STATIC,216,47,16,8\r\n    LTEXT           \"ֵƽ\",IDC_STATIC,132,62,30,8\r\n    EDITTEXT        IDC_RECVTHRESHOLD,166,60,45,12,ES_AUTOHSCROLL\r\n    LTEXT           \"0~1.0\",IDC_STATIC,216,62,19,8\r\n    LTEXT           \"ʼƵ\",IDC_STATIC,132,77,30,8\r\n    EDITTEXT        IDC_RECVFREQSTART,166,75,45,12,ES_AUTOHSCROLL | ES_NUMBER\r\n    LTEXT           \"(Hz)\",IDC_STATIC,216,77,14,8\r\n    LTEXT           \"ֹƵ\",IDC_STATIC,132,92,30,8\r\n    EDITTEXT        IDC_RECVFREQEND,166,90,45,12,ES_AUTOHSCROLL | ES_NUMBER\r\n    LTEXT           \"(Hz)\",IDC_STATIC,216,92,14,8\r\n    GROUPBOX        \"CW\",IDC_STATIC,3,110,237,45\r\n    LTEXT           \"\"\"\"\"\",IDC_STATIC,7,122,30,8\r\n    EDITTEXT        IDC_SHORTHIT,36,120,25,12,ES_AUTOHSCROLL | ES_NUMBER\r\n    LTEXT           \"(ms)\",IDC_STATIC,65,122,16,8\r\n    LTEXT           \"\"\"\"\"\",IDC_STATIC,7,136,30,8\r\n    EDITTEXT        IDC_LONGHIT,36,135,25,12,ES_AUTOHSCROLL | ES_NUMBER\r\n    LTEXT           \"(ms)\",IDC_STATIC,65,136,16,8\r\n    LTEXT           \"\",IDC_STATIC,88,121,30,8\r\n    EDITTEXT        IDC_HITDELAY,117,120,25,12,ES_AUTOHSCROLL | ES_NUMBER\r\n    LTEXT           \"(ms)\",IDC_STATIC,147,136,16,8\r\n    LTEXT           \"ַ\",IDC_STATIC,88,136,30,8\r\n    EDITTEXT        IDC_LETTERDELAY,117,135,25,12,ES_AUTOHSCROLL | ES_NUMBER\r\n    LTEXT           \"(ms)\",IDC_STATIC,147,121,16,8\r\n    LTEXT           \"\",IDC_STATIC,170,121,30,8\r\n    EDITTEXT        IDC_SPEED,187,120,25,12,ES_AUTOHSCROLL | ES_NUMBER\r\n    LTEXT           \"(wpm)\",IDC_STATIC,216,121,20,8\r\n    PUSHBUTTON      \"\",IDC_CALCSPEED,170,136,66,10\r\n    GROUPBOX        \"˿ڿ\",IDC_STATIC,3,156,237,28\r\n    CONTROL         \"\",IDC_EXTPORTENABLE,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,7,168,32,8\r\n    LTEXT           \"ַ(HEX)\",IDC_STATIC,51,168,32,8\r\n    EDITTEXT        IDC_EXTPORTADDR,85,166,32,12,ES_UPPERCASE | ES_READONLY\r\n    LTEXT           \"(HEX)\",IDC_STATIC,125,168,32,8\r\n    EDITTEXT        IDC_OPENBYTE,161,166,13,12,ES_UPPERCASE\r\n    LTEXT           \"ر(HEX)\",IDC_STATIC,181,168,32,8\r\n    EDITTEXT        IDC_CLOSEBYTE,215,166,13,12,ES_UPPERCASE\r\n    GROUPBOX        \"ϰ\",IDC_STATIC,3,190,237,28\r\n    LTEXT           \"ַ\",IDC_STATIC,7,202,32,8\r\n    EDITTEXT        IDC_KOCHCHARS,41,200,138,12,ES_UPPERCASE | ES_AUTOHSCROLL | ES_WANTRETURN\r\n    LTEXT           \"ֳ\",IDC_STATIC,186,202,32,8\r\n    EDITTEXT        IDC_KOCHWORDLEN,215,200,16,12,ES_AUTOHSCROLL | ES_NUMBER\r\n    PUSHBUTTON      \"ȷ\",IDC_ACCEPT,190,224,47,10\r\n    PUSHBUTTON      \"ȡ\",IDCANCEL,135,224,47,10\r\nEND\r\n\r\n\r\n#ifdef APSTUDIO_INVOKED\r\n/////////////////////////////////////////////////////////////////////////////\r\n//\r\n// TEXTINCLUDE\r\n//\r\n\r\n1 TEXTINCLUDE \r\nBEGIN\r\n    \"resource.h\\0\"\r\nEND\r\n\r\n2 TEXTINCLUDE \r\nBEGIN\r\n    \"#define APSTUDIO_HIDDEN_SYMBOLS\\r\\n\"\r\n    \"#include \"\"windows.h\"\"\\r\\n\"\r\n    \"#undef APSTUDIO_HIDDEN_SYMBOLS\\r\\n\"\r\n    \"\\0\"\r\nEND\r\n\r\n3 TEXTINCLUDE \r\nBEGIN\r\n    \"\\r\\n\"\r\n    \"\\0\"\r\nEND\r\n\r\n#endif    // APSTUDIO_INVOKED\r\n\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n//\r\n// DESIGNINFO\r\n//\r\n\r\n#ifdef APSTUDIO_INVOKED\r\nGUIDELINES DESIGNINFO\r\nBEGIN\r\n    IDD_ABOUTBOX, DIALOG\r\n    BEGIN\r\n        RIGHTMARGIN, 213\r\n        BOTTOMMARGIN, 72\r\n    END\r\n\r\n    IDD_SETTINGS, DIALOG\r\n    BEGIN\r\n        RIGHTMARGIN, 251\r\n    END\r\n\r\n    IDD_TEST, DIALOG\r\n    BEGIN\r\n        LEFTMARGIN, 7\r\n        RIGHTMARGIN, 341\r\n        TOPMARGIN, 7\r\n        BOTTOMMARGIN, 141\r\n    END\r\n\r\n    IDD_GENERAL, DIALOG\r\n    BEGIN\r\n        BOTTOMMARGIN, 161\r\n    END\r\n\r\n    IDD_SEND, DIALOG\r\n    BEGIN\r\n        RIGHTMARGIN, 280\r\n        BOTTOMMARGIN, 160\r\n    END\r\n\r\n    IDD_RECV, DIALOG\r\n    BEGIN\r\n        BOTTOMMARGIN, 122\r\n    END\r\n\r\n    IDD_IO, DIALOG\r\n    BEGIN\r\n        BOTTOMMARGIN, 122\r\n    END\r\n\r\n    IDD_KOCH, DIALOG\r\n    BEGIN\r\n        BOTTOMMARGIN, 152\r\n    END\r\n\r\n    IDD_NETWORK, DIALOG\r\n    BEGIN\r\n        BOTTOMMARGIN, 152\r\n    END\r\nEND\r\n#endif    // APSTUDIO_INVOKED\r\n\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n//\r\n// Bitmap\r\n//\r\n\r\nIDB_LOGO                BITMAP                  \"logo.bmp\"\r\n\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n//\r\n// String Table\r\n//\r\n\r\nSTRINGTABLE\r\nBEGIN\r\n    IDS_APP_TITLE           \"Lakey 2.2 (Paper)\"\r\n    IDC_LAKEY               \"LAKEY\"\r\nEND\r\n\r\n#endif    // (壬й) resources\r\n/////////////////////////////////////////////////////////////////////////////\r\n\r\n\r\n\r\n#ifndef APSTUDIO_INVOKED\r\n/////////////////////////////////////////////////////////////////////////////\r\n//\r\n// Generated from the TEXTINCLUDE 3 resource.\r\n//\r\n\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n#endif    // not APSTUDIO_INVOKED\r\n\r\n"
  },
  {
    "path": "src/Lakey.sln",
    "content": "﻿\r\nMicrosoft Visual Studio Solution File, Format Version 12.00\r\n# Visual Studio Version 16\r\nVisualStudioVersion = 16.0.31313.79\r\nMinimumVisualStudioVersion = 10.0.40219.1\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"Lakey\", \"Lakey.vcxproj\", \"{B20DFA3B-4DF4-464C-883D-940012A2178C}\"\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"test4fft\", \"..\\test4fft\\test4fft.vcxproj\", \"{5A8D8698-A0EF-404A-B421-B49C0336EEB4}\"\r\nEndProject\r\nGlobal\r\n\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\r\n\t\tDebug|Win32 = Debug|Win32\r\n\t\tRelease|Win32 = Release|Win32\r\n\tEndGlobalSection\r\n\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\r\n\t\t{B20DFA3B-4DF4-464C-883D-940012A2178C}.Debug|Win32.ActiveCfg = Debug|Win32\r\n\t\t{B20DFA3B-4DF4-464C-883D-940012A2178C}.Debug|Win32.Build.0 = Debug|Win32\r\n\t\t{B20DFA3B-4DF4-464C-883D-940012A2178C}.Release|Win32.ActiveCfg = Release|Win32\r\n\t\t{B20DFA3B-4DF4-464C-883D-940012A2178C}.Release|Win32.Build.0 = Release|Win32\r\n\t\t{5A8D8698-A0EF-404A-B421-B49C0336EEB4}.Debug|Win32.ActiveCfg = Debug|Win32\r\n\t\t{5A8D8698-A0EF-404A-B421-B49C0336EEB4}.Debug|Win32.Build.0 = Debug|Win32\r\n\t\t{5A8D8698-A0EF-404A-B421-B49C0336EEB4}.Release|Win32.ActiveCfg = Release|Win32\r\n\t\t{5A8D8698-A0EF-404A-B421-B49C0336EEB4}.Release|Win32.Build.0 = Release|Win32\r\n\tEndGlobalSection\r\n\tGlobalSection(SolutionProperties) = preSolution\r\n\t\tHideSolutionNode = FALSE\r\n\tEndGlobalSection\r\n\tGlobalSection(ExtensibilityGlobals) = postSolution\r\n\t\tSolutionGuid = {779ADF4C-AB52-4F67-9F6C-1407590493CD}\r\n\tEndGlobalSection\r\nEndGlobal\r\n"
  },
  {
    "path": "src/Lakey.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"gb2312\"?>\r\n<VisualStudioProject\r\n\tProjectType=\"Visual C++\"\r\n\tVersion=\"8.00\"\r\n\tName=\"Lakey\"\r\n\tProjectGUID=\"{B20DFA3B-4DF4-464C-883D-940012A2178C}\"\r\n\tRootNamespace=\"Lakey\"\r\n\tKeyword=\"Win32Proj\"\r\n\t>\r\n\t<Platforms>\r\n\t\t<Platform\r\n\t\t\tName=\"Win32\"\r\n\t\t/>\r\n\t</Platforms>\r\n\t<ToolFiles>\r\n\t</ToolFiles>\r\n\t<Configurations>\r\n\t\t<Configuration\r\n\t\t\tName=\"Debug|Win32\"\r\n\t\t\tOutputDirectory=\"Debug\"\r\n\t\t\tIntermediateDirectory=\"Debug\"\r\n\t\t\tConfigurationType=\"1\"\r\n\t\t\tInheritedPropertySheets=\"$(VCInstallDir)VCProjectDefaults\\UpgradeFromVC70.vsprops\"\r\n\t\t\tCharacterSet=\"2\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tOptimization=\"0\"\r\n\t\t\t\tAdditionalIncludeDirectories=\"\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_WIN32_WINNT=0x0600;_WIN32_IE=0x0800\"\r\n\t\t\t\tMinimalRebuild=\"true\"\r\n\t\t\t\tBasicRuntimeChecks=\"3\"\r\n\t\t\t\tRuntimeLibrary=\"1\"\r\n\t\t\t\tUsePrecompiledHeader=\"2\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"true\"\r\n\t\t\t\tDebugInformationFormat=\"4\"\r\n\t\t\t\tCallingConvention=\"0\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tAdditionalDependencies=\"dxguid.lib dsound.lib WS2_32.lib Comdlg32.lib User32.lib Gdi32.lib\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/Lakey.exe\"\r\n\t\t\t\tLinkIncremental=\"2\"\r\n\t\t\t\tAdditionalLibraryDirectories=\"\"\r\n\t\t\t\tGenerateDebugInformation=\"true\"\r\n\t\t\t\tProgramDatabaseFile=\"$(OutDir)/Lakey.pdb\"\r\n\t\t\t\tSubSystem=\"2\"\r\n\t\t\t\tTargetMachine=\"1\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManifestTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAppVerifierTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebDeploymentTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"Release|Win32\"\r\n\t\t\tOutputDirectory=\"Release\"\r\n\t\t\tIntermediateDirectory=\"Release\"\r\n\t\t\tConfigurationType=\"1\"\r\n\t\t\tInheritedPropertySheets=\"$(VCInstallDir)VCProjectDefaults\\UpgradeFromVC70.vsprops\"\r\n\t\t\tCharacterSet=\"2\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tOptimization=\"2\"\r\n\t\t\t\tInlineFunctionExpansion=\"1\"\r\n\t\t\t\tOmitFramePointers=\"true\"\r\n\t\t\t\tPreprocessorDefinitions=\"_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_WIN32_WINNT=0x0600;_WIN32_IE=0x0800\"\r\n\t\t\t\tStringPooling=\"true\"\r\n\t\t\t\tRuntimeLibrary=\"0\"\r\n\t\t\t\tEnableFunctionLevelLinking=\"true\"\r\n\t\t\t\tUsePrecompiledHeader=\"2\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"true\"\r\n\t\t\t\tDebugInformationFormat=\"3\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tAdditionalDependencies=\"dxguid.lib dsound.lib WS2_32.lib Comdlg32.lib User32.lib Gdi32.lib\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/Lakey.exe\"\r\n\t\t\t\tLinkIncremental=\"1\"\r\n\t\t\t\tGenerateDebugInformation=\"true\"\r\n\t\t\t\tSubSystem=\"2\"\r\n\t\t\t\tOptimizeReferences=\"2\"\r\n\t\t\t\tEnableCOMDATFolding=\"2\"\r\n\t\t\t\tTargetMachine=\"1\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManifestTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAppVerifierTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebDeploymentTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t</Configurations>\r\n\t<References>\r\n\t</References>\r\n\t<Files>\r\n\t\t<Filter\r\n\t\t\tName=\"Դļ\"\r\n\t\t\tFilter=\"cpp;c;cxx;def;odl;idl;hpj;bat;asm\"\r\n\t\t\t>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\".\\CommFunc.cpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"EventListener.cpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"EventManagerWin32.cpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"FFT.cpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"Graphics.cpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"LaButton.cpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\".\\LaHwControl.cpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"LaJournalPanel.cpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\".\\LakeyMain.cpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"LakeyMainWindow.cpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"LakeySetting.cpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"LaLabel.cpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"LaLine.cpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\".\\LaNetwork.cpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"LaTuner.cpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"LaWaveCapture.cpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\".\\LaWaveFile.cpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"MorseParser.cpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\".\\mytest.cpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"SinSound.cpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"stdafx.cpp\"\r\n\t\t\t\t>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Debug|Win32\"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tUsePrecompiledHeader=\"1\"\r\n\t\t\t\t\t/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Release|Win32\"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tUsePrecompiledHeader=\"1\"\r\n\t\t\t\t\t/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"ͷļ\"\r\n\t\t\tFilter=\"h;hpp;hxx;hm;inl;inc\"\r\n\t\t\t>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\".\\CommFunc.h\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"EventListener.h\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"EventManagerWin32.h\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"FFT.h\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"Graphics.h\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"LaButton.h\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\".\\LaHwControl.h\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"LaJournalPanel.h\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"Lakey.h\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"LakeyMainWindow.h\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"LakeySetting.h\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"LaLabel.h\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"LaLine.h\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\".\\LaNetwork.h\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"LaTuner.h\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"LaWaveCapture.h\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\".\\LaWaveFile.h\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"MorseParser.h\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\".\\mytest.h\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"Resource.h\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"SinSound.h\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"stdafx.h\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\".\\WinIo.h\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Դļ\"\r\n\t\t\tFilter=\"rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\r\n\t\t\t>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"Lakey.ico\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\".\\lakey.ini\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"Lakey.rc\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"logo.bmp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"mc.txt\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"small.ico\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t\t<File\r\n\t\t\tRelativePath=\"ReadMe.txt\"\r\n\t\t\t>\r\n\t\t</File>\r\n\t\t<File\r\n\t\t\tRelativePath=\".\\WinIo.lib\"\r\n\t\t\t>\r\n\t\t</File>\r\n\t</Files>\r\n\t<Globals>\r\n\t</Globals>\r\n</VisualStudioProject>\r\n"
  },
  {
    "path": "src/Lakey.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup Label=\"ProjectConfigurations\">\r\n    <ProjectConfiguration Include=\"Debug|Win32\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Debug|x64\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|Win32\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|x64\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n  </ItemGroup>\r\n  <PropertyGroup Label=\"Globals\">\r\n    <ProjectGuid>{B20DFA3B-4DF4-464C-883D-940012A2178C}</ProjectGuid>\r\n    <RootNamespace>Lakey</RootNamespace>\r\n    <Keyword>Win32Proj</Keyword>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>Application</ConfigurationType>\r\n    <CharacterSet>MultiByte</CharacterSet>\r\n    <PlatformToolset>v142</PlatformToolset>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>Application</ConfigurationType>\r\n    <CharacterSet>MultiByte</CharacterSet>\r\n    <PlatformToolset>v142</PlatformToolset>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>Application</ConfigurationType>\r\n    <CharacterSet>MultiByte</CharacterSet>\r\n    <PlatformToolset>v142</PlatformToolset>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>Application</ConfigurationType>\r\n    <CharacterSet>MultiByte</CharacterSet>\r\n    <PlatformToolset>v142</PlatformToolset>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\r\n  <ImportGroup Label=\"ExtensionSettings\">\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <PropertyGroup>\r\n    <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">Debug\\</OutDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">Debug\\</IntDir>\r\n    <LinkIncremental Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">true</LinkIncremental>\r\n    <LinkIncremental Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">true</LinkIncremental>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">Release\\</OutDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">Release\\</IntDir>\r\n    <LinkIncremental Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">false</LinkIncremental>\r\n    <LinkIncremental Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">false</LinkIncremental>\r\n    <IncludePath Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">$(DXSDK_DIR)include;$(IncludePath)</IncludePath>\r\n    <IncludePath Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">$(DXSDK_DIR)include;$(IncludePath)</IncludePath>\r\n    <LibraryPath Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">$(DXSDK_DIR)lib\\x86;$(LibraryPath)</LibraryPath>\r\n    <LibraryPath Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">$(DXSDK_DIR)lib\\x86;$(LibraryPath)</LibraryPath>\r\n    <IncludePath Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">$(DXSDK_DIR)include;$(IncludePath)</IncludePath>\r\n    <IncludePath Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">$(DXSDK_DIR)include;$(IncludePath)</IncludePath>\r\n    <LibraryPath Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">$(DXSDK_DIR)lib\\x86;$(LibraryPath)</LibraryPath>\r\n    <LibraryPath Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">$(DXSDK_DIR)lib\\x86;$(LibraryPath)</LibraryPath>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\r\n    <ClCompile>\r\n      <Optimization>Disabled</Optimization>\r\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_WIN32_WINNT=0x0600;_WIN32_IE=0x0800;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <MinimalRebuild>true</MinimalRebuild>\r\n      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r\n      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\r\n      <PrecompiledHeader>Use</PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>EditAndContinue</DebugInformationFormat>\r\n      <CallingConvention>Cdecl</CallingConvention>\r\n    </ClCompile>\r\n    <Link>\r\n      <AdditionalDependencies>dxguid.lib;dsound.lib;WS2_32.lib;Comdlg32.lib;User32.lib;Gdi32.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <OutputFile>$(OutDir)Lakey.exe</OutputFile>\r\n      <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <ProgramDatabaseFile>$(OutDir)Lakey.pdb</ProgramDatabaseFile>\r\n      <SubSystem>Windows</SubSystem>\r\n      <TargetMachine>MachineX86</TargetMachine>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <ClCompile>\r\n      <Optimization>Disabled</Optimization>\r\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_WIN32_WINNT=0x0600;_WIN32_IE=0x0800;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r\n      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\r\n      <PrecompiledHeader>Use</PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n      <CallingConvention>Cdecl</CallingConvention>\r\n    </ClCompile>\r\n    <Link>\r\n      <AdditionalDependencies>dxguid.lib;dsound.lib;WS2_32.lib;Comdlg32.lib;User32.lib;Gdi32.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <OutputFile>$(OutDir)Lakey.exe</OutputFile>\r\n      <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <ProgramDatabaseFile>$(OutDir)Lakey.pdb</ProgramDatabaseFile>\r\n      <SubSystem>Windows</SubSystem>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\r\n    <ClCompile>\r\n      <Optimization>MaxSpeed</Optimization>\r\n      <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>\r\n      <OmitFramePointers>true</OmitFramePointers>\r\n      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_WIN32_WINNT=0x0600;_WIN32_IE=0x0800;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <StringPooling>true</StringPooling>\r\n      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\r\n      <FunctionLevelLinking>true</FunctionLevelLinking>\r\n      <PrecompiledHeader>Use</PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n    </ClCompile>\r\n    <Link>\r\n      <AdditionalDependencies>dxguid.lib;dsound.lib;WS2_32.lib;Comdlg32.lib;User32.lib;Gdi32.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <OutputFile>$(OutDir)Lakey.exe</OutputFile>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <SubSystem>Windows</SubSystem>\r\n      <OptimizeReferences>true</OptimizeReferences>\r\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r\n      <TargetMachine>MachineX86</TargetMachine>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <ClCompile>\r\n      <Optimization>MaxSpeed</Optimization>\r\n      <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>\r\n      <OmitFramePointers>true</OmitFramePointers>\r\n      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_WIN32_WINNT=0x0600;_WIN32_IE=0x0800;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <StringPooling>true</StringPooling>\r\n      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\r\n      <FunctionLevelLinking>true</FunctionLevelLinking>\r\n      <PrecompiledHeader>Use</PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n    </ClCompile>\r\n    <Link>\r\n      <AdditionalDependencies>dxguid.lib;dsound.lib;WS2_32.lib;Comdlg32.lib;User32.lib;Gdi32.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <OutputFile>$(OutDir)Lakey.exe</OutputFile>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <SubSystem>Windows</SubSystem>\r\n      <OptimizeReferences>true</OptimizeReferences>\r\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"CommFunc.cpp\" />\r\n    <ClCompile Include=\"EventListener.cpp\" />\r\n    <ClCompile Include=\"EventManagerWin32.cpp\" />\r\n    <ClCompile Include=\"FFT.cpp\" />\r\n    <ClCompile Include=\"Graphics.cpp\" />\r\n    <ClCompile Include=\"LaButton.cpp\" />\r\n    <ClCompile Include=\"LaHwControl.cpp\" />\r\n    <ClCompile Include=\"LaJournalPanel.cpp\" />\r\n    <ClCompile Include=\"LakeyMain.cpp\" />\r\n    <ClCompile Include=\"LakeyMainWindow.cpp\" />\r\n    <ClCompile Include=\"LakeySetting.cpp\" />\r\n    <ClCompile Include=\"LaLabel.cpp\" />\r\n    <ClCompile Include=\"LaLine.cpp\" />\r\n    <ClCompile Include=\"LaNetwork.cpp\" />\r\n    <ClCompile Include=\"LaSpectrogram.cpp\" />\r\n    <ClCompile Include=\"LaTuner.cpp\" />\r\n    <ClCompile Include=\"LaWaveCapture.cpp\" />\r\n    <ClCompile Include=\"LaWaveFile.cpp\" />\r\n    <ClCompile Include=\"MorseParser.cpp\" />\r\n    <ClCompile Include=\"mytest.cpp\" />\r\n    <ClCompile Include=\"SinSound.cpp\" />\r\n    <ClCompile Include=\"stdafx.cpp\">\r\n      <PrecompiledHeader Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">Create</PrecompiledHeader>\r\n      <PrecompiledHeader Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">Create</PrecompiledHeader>\r\n      <PrecompiledHeader Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">Create</PrecompiledHeader>\r\n      <PrecompiledHeader Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">Create</PrecompiledHeader>\r\n    </ClCompile>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"CommFunc.h\" />\r\n    <ClInclude Include=\"EventListener.h\" />\r\n    <ClInclude Include=\"EventManagerWin32.h\" />\r\n    <ClInclude Include=\"FFT.h\" />\r\n    <ClInclude Include=\"Graphics.h\" />\r\n    <ClInclude Include=\"LaButton.h\" />\r\n    <ClInclude Include=\"LaHwControl.h\" />\r\n    <ClInclude Include=\"LaJournalPanel.h\" />\r\n    <ClInclude Include=\"Lakey.h\" />\r\n    <ClInclude Include=\"LakeyMainWindow.h\" />\r\n    <ClInclude Include=\"LakeySetting.h\" />\r\n    <ClInclude Include=\"LaLabel.h\" />\r\n    <ClInclude Include=\"LaLine.h\" />\r\n    <ClInclude Include=\"LaNetwork.h\" />\r\n    <ClInclude Include=\"LaSpectrogram.h\" />\r\n    <ClInclude Include=\"LaTuner.h\" />\r\n    <ClInclude Include=\"LaWaveCapture.h\" />\r\n    <ClInclude Include=\"LaWaveFile.h\" />\r\n    <ClInclude Include=\"MorseParser.h\" />\r\n    <ClInclude Include=\"mytest.h\" />\r\n    <ClInclude Include=\"Resource.h\" />\r\n    <ClInclude Include=\"SinSound.h\" />\r\n    <ClInclude Include=\"stdafx.h\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"..\\MANUAL\\index.html\">\r\n      <SubType>Designer</SubType>\r\n    </None>\r\n    <None Include=\"Lakey.ico\" />\r\n    <None Include=\"lakey.ini\" />\r\n    <None Include=\"logo.bmp\" />\r\n    <None Include=\"mc.txt\" />\r\n    <None Include=\"small.ico\" />\r\n    <None Include=\"ReadMe.txt\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ResourceCompile Include=\"Lakey.rc\" />\r\n  </ItemGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\r\n  <ImportGroup Label=\"ExtensionTargets\">\r\n  </ImportGroup>\r\n</Project>"
  },
  {
    "path": "src/Lakey.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup>\r\n    <Filter Include=\"源文件\">\r\n      <UniqueIdentifier>{4afbbfc2-bf6b-49a7-ac06-2381afa2f2cc}</UniqueIdentifier>\r\n      <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"头文件\">\r\n      <UniqueIdentifier>{8e69d1d8-f0fa-4505-afa8-68c0163cbf89}</UniqueIdentifier>\r\n      <Extensions>h;hpp;hxx;hm;inl;inc</Extensions>\r\n    </Filter>\r\n    <Filter Include=\"资源文件\">\r\n      <UniqueIdentifier>{61be6223-e008-4882-b33e-1feda47e14f1}</UniqueIdentifier>\r\n      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>\r\n    </Filter>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"CommFunc.cpp\">\r\n      <Filter>源文件</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"EventListener.cpp\">\r\n      <Filter>源文件</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"EventManagerWin32.cpp\">\r\n      <Filter>源文件</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"FFT.cpp\">\r\n      <Filter>源文件</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Graphics.cpp\">\r\n      <Filter>源文件</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"LaButton.cpp\">\r\n      <Filter>源文件</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"LaHwControl.cpp\">\r\n      <Filter>源文件</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"LaJournalPanel.cpp\">\r\n      <Filter>源文件</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"LakeyMain.cpp\">\r\n      <Filter>源文件</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"LakeyMainWindow.cpp\">\r\n      <Filter>源文件</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"LakeySetting.cpp\">\r\n      <Filter>源文件</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"LaLabel.cpp\">\r\n      <Filter>源文件</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"LaLine.cpp\">\r\n      <Filter>源文件</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"LaNetwork.cpp\">\r\n      <Filter>源文件</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"LaTuner.cpp\">\r\n      <Filter>源文件</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"LaWaveCapture.cpp\">\r\n      <Filter>源文件</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"LaWaveFile.cpp\">\r\n      <Filter>源文件</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"MorseParser.cpp\">\r\n      <Filter>源文件</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"mytest.cpp\">\r\n      <Filter>源文件</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"SinSound.cpp\">\r\n      <Filter>源文件</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"stdafx.cpp\">\r\n      <Filter>源文件</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"LaSpectrogram.cpp\">\r\n      <Filter>源文件</Filter>\r\n    </ClCompile>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"CommFunc.h\">\r\n      <Filter>头文件</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"EventListener.h\">\r\n      <Filter>头文件</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"EventManagerWin32.h\">\r\n      <Filter>头文件</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"FFT.h\">\r\n      <Filter>头文件</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Graphics.h\">\r\n      <Filter>头文件</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"LaButton.h\">\r\n      <Filter>头文件</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"LaHwControl.h\">\r\n      <Filter>头文件</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"LaJournalPanel.h\">\r\n      <Filter>头文件</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Lakey.h\">\r\n      <Filter>头文件</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"LakeyMainWindow.h\">\r\n      <Filter>头文件</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"LakeySetting.h\">\r\n      <Filter>头文件</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"LaLabel.h\">\r\n      <Filter>头文件</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"LaLine.h\">\r\n      <Filter>头文件</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"LaNetwork.h\">\r\n      <Filter>头文件</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"LaTuner.h\">\r\n      <Filter>头文件</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"LaWaveCapture.h\">\r\n      <Filter>头文件</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"LaWaveFile.h\">\r\n      <Filter>头文件</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"MorseParser.h\">\r\n      <Filter>头文件</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"mytest.h\">\r\n      <Filter>头文件</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Resource.h\">\r\n      <Filter>头文件</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"SinSound.h\">\r\n      <Filter>头文件</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"stdafx.h\">\r\n      <Filter>头文件</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"LaSpectrogram.h\">\r\n      <Filter>头文件</Filter>\r\n    </ClInclude>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"Lakey.ico\">\r\n      <Filter>资源文件</Filter>\r\n    </None>\r\n    <None Include=\"lakey.ini\">\r\n      <Filter>资源文件</Filter>\r\n    </None>\r\n    <None Include=\"logo.bmp\">\r\n      <Filter>资源文件</Filter>\r\n    </None>\r\n    <None Include=\"mc.txt\">\r\n      <Filter>资源文件</Filter>\r\n    </None>\r\n    <None Include=\"small.ico\">\r\n      <Filter>资源文件</Filter>\r\n    </None>\r\n    <None Include=\"ReadMe.txt\" />\r\n    <None Include=\"..\\MANUAL\\index.html\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ResourceCompile Include=\"Lakey.rc\">\r\n      <Filter>资源文件</Filter>\r\n    </ResourceCompile>\r\n  </ItemGroup>\r\n</Project>"
  },
  {
    "path": "src/Lakey.vcxproj.user",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n</Project>"
  },
  {
    "path": "src/LakeyMain.cpp",
    "content": "// LakeyMain.cpp : Ӧóڵ㡣\r\n//\r\n\r\n#include \"stdafx.h\"\r\n#include \"Lakey.h\"\r\n#include \"windows.h\"\r\n#include \"Richedit.h\"\r\n#include \"commctrl.h\"\r\n#include <time.h>\r\n#include <ctype.h>\r\n\r\n#include \"LakeyMainWindow.h\"\r\n#include \"LakeySetting.h\"\r\n#include \"LaWaveFile.h\"\r\n\r\n#include \"CommFunc.h\"\r\n#include \"mytest.h\"\r\n\r\n//#include \"winio.h\"\r\n\r\n#define MAX_LOADSTRING\t100\r\n#define MAX_KOCH_SAMPLE\t\t256\r\n#define SAFE_DELETE(x)\t\tif (x) { delete x; x = NULL; }\r\n#define PROMPT_BUFF_LEN\t\t256\r\n\r\n#define SETTING_PAGES 6\r\n \r\n// ȫֱ\r\nHINSTANCE hInst;\t\t\t\t\t\t\t\t// ǰʵ\r\nTCHAR szTitle[MAX_LOADSTRING];\t\t\t\t\t// ı\r\nTCHAR szWindowClass[MAX_LOADSTRING];\t\t\t// \r\n\r\nCLakeyMainWindow*\tg_pMainWnd = NULL;\r\nCLakeySetting*\t\tg_pGlobalSetting = NULL;\r\nCUSTOMIZE\t\t\tg_oTmpCust;\r\nHostList\t\t\tg_oTmpHosts;\r\nHWND\t\t\t\tg_hWnd = NULL;\r\n\r\nchar\t\t\t\tg_vCopyText[MAX_KOCH_SAMPLE + 1];\r\nchar\t\t\t\tg_vKochSample[MAX_KOCH_SAMPLE];\r\nchar g_vPromptText[PROMPT_BUFF_LEN];\r\nchar g_vPromptBuff[PROMPT_BUFF_LEN] = {'\\0'};\r\n\r\n\r\n// ˴ģаĺǰ\r\nATOM\t\t\t\tMyRegisterClass(HINSTANCE hInstance);\r\nBOOL\t\t\t\tInitInstance(HINSTANCE, int);\r\nLRESULT CALLBACK\tWndProc(HWND, UINT, WPARAM, LPARAM);\r\nLRESULT CALLBACK\tAbout(HWND, UINT, WPARAM, LPARAM);\r\n\r\nLRESULT CALLBACK\tSettings(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);\r\nINT_PTR CALLBACK\tSettingsPage(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);\r\nBOOL\t\t\t\tOnSettingsInit(HWND hDlg);\r\nvoid\t\t\t\tDestroyCurrPage(HWND hDlg);\r\nvoid\t\t\t\tSaveTemp(HWND hDlg);\r\nvoid\t\t\t\tAddHost(HWND hCtrl, HOSTNODE* pNode);\r\n\r\nLRESULT CALLBACK\tCopyPad(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);\r\nLRESULT CALLBACK\tTestDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);\r\nLRESULT CALLBACK\tPromptProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);\r\n\r\nconst char* ConvertKochPathname(char* pDest, const char* pSrc, UINT nBuffLen);\r\nvoid InitKochSample();\r\nvoid PromptToWave(HWND hWnd);\r\nvoid KochToWave(HWND hWnd);\r\nvoid TextToWave(const char* pPathname, const char* pTxt, UINT nTxtLen, UINT nWordLen);\r\nvoid TextToAskWave(char* pWavePathBuff, UINT nWavePathBuffSize, const char* pBuff, UINT nCount, HWND hWnd);\r\nvoid CalcSpeed(HWND hDlg);\r\n\r\nint APIENTRY _tWinMain(HINSTANCE hInstance,\r\n                     HINSTANCE hPrevInstance,\r\n                     LPTSTR    lpCmdLine,\r\n                     int       nCmdShow)\r\n{\r\n//\tApplication::EnableVisualStyles();\r\n//\tApplication::SetCompatibleTextRenderingDefault(false); \r\n\r\n\tInitCommonControls();\r\n\tg_pGlobalSetting = new CLakeySetting();\r\n\r\n\t// TODO: ڴ˷ô롣\r\n\tMSG msg;\r\n\tHACCEL hAccelTable;\r\n\r\n\t// ʼȫַ\r\n\tLoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);\r\n\tLoadString(hInstance, IDC_LAKEY, szWindowClass, MAX_LOADSTRING);\r\n\tMyRegisterClass(hInstance);\r\n\r\n\t// ִӦóʼ\r\n\tif (!InitInstance (hInstance, nCmdShow)) \r\n\t{\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\thAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_LAKEY);\r\n\r\n\t// Ϣѭ\r\n\twhile (GetMessage(&msg, NULL, 0, 0)) \r\n\t{\r\n\t\tif (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) \r\n\t\t{\r\n\t\t\tTranslateMessage(&msg);\r\n\t\t\tDispatchMessage(&msg);\r\n\t\t}\r\n\t}\r\n\r\n\tdelete g_pGlobalSetting;\r\n\r\n\treturn (int) msg.wParam;\r\n}\r\n\r\n//\r\n//  MyRegisterClass()\r\n//\r\n//  Ŀģעᴰࡣ\r\n//\r\n//  עͣ\r\n//\r\n//    ϣӵ Windows 95 \r\n//    RegisterClassEx֮ǰ˴ Win32 ϵͳʱ\r\n//    Ҫ˺÷ô˺\r\n//    ʮҪӦóͿԻù\r\n//   ʽȷġСͼꡣ\r\n//\r\nATOM MyRegisterClass(HINSTANCE hInstance)\r\n{\r\n\tWNDCLASSEX wcex;\r\n\r\n\twcex.cbSize = sizeof(WNDCLASSEX); \r\n\r\n\twcex.style\t\t\t= CS_HREDRAW | CS_VREDRAW;\r\n\twcex.lpfnWndProc\t= (WNDPROC)WndProc;\r\n\twcex.cbClsExtra\t\t= 0;\r\n\twcex.cbWndExtra\t\t= 0;\r\n\twcex.hInstance\t\t= hInstance;\r\n\twcex.hIcon\t\t\t= LoadIcon(hInstance, (LPCTSTR)IDI_LAKEY);\r\n\twcex.hCursor\t\t= LoadCursor(NULL, IDC_ARROW);\r\n\twcex.hbrBackground\t= (HBRUSH)(COLOR_WINDOW);\r\n\twcex.lpszMenuName\t= (LPCTSTR)IDC_LAKEY;\r\n\twcex.lpszClassName\t= szWindowClass;\r\n\twcex.hIconSm\t\t= LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);\r\n\r\n\treturn RegisterClassEx(&wcex);\r\n}\r\n\r\n//\r\n//   InitInstance(HANDLE, int)\r\n//\r\n//   Ŀģʵ\r\n//\r\n//   עͣ\r\n//\r\n//        ڴ˺Уȫֱбʵ\r\n//        ʾ򴰿ڡ\r\n//\r\nBOOL InitInstance(HINSTANCE hInstance, int nCmdShow)\r\n{\r\n\thInst = hInstance; // ʵ洢ȫֱ\r\n\r\n\tg_hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW ^ WS_THICKFRAME,\r\n\t\tg_pGlobalSetting->cust.m_oWindowRect.left, g_pGlobalSetting->cust.m_oWindowRect.top\r\n\t\t, g_pGlobalSetting->cust.m_oWindowRect.right - g_pGlobalSetting->cust.m_oWindowRect.left\r\n\t\t, g_pGlobalSetting->cust.m_oWindowRect.bottom - g_pGlobalSetting->cust.m_oWindowRect.top\r\n\t\t, NULL, NULL, hInstance, NULL);\r\n\r\n\tif (!g_hWnd)\r\n\t{\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\tg_pMainWnd = new CLakeyMainWindow(g_hWnd, g_pGlobalSetting);\r\n\r\n\t::LoadLibrary(\"RICHED20.dll\");\r\n\r\n\tif (!g_pMainWnd->Initialize())\r\n\t\treturn FALSE;\r\n\r\n\tg_pMainWnd->NetworkStartup();\r\n\r\n\tShowWindow(g_hWnd, nCmdShow);\r\n\tUpdateWindow(g_hWnd);\r\n\r\n\treturn TRUE;\r\n}\r\n\r\n//\r\n//  WndProc(HWND, unsigned, WORD, LONG)\r\n//\r\n//  ĿģڵϢ\r\n//\r\n//  WM_COMMAND\t- Ӧó˵\r\n//  WM_PAINT\t- \r\n//  WM_DESTROY\t- ˳Ϣ\r\n//\r\n//\r\nLRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)\r\n{\r\n\tint wmId, wmEvent;\r\n//\tPAINTSTRUCT ps;\r\n//\tHDC hdc;\r\n\r\n\tLRESULT r;\r\n\tif (g_pMainWnd)\r\n\t\tif (g_pMainWnd->OnMessage(message, wParam, lParam, &r))\r\n\t\t\treturn TRUE;\r\n\r\n\tswitch (message) \r\n\t{\r\n\t\tcase WM_COMMAND:\r\n\t\t\twmId    = LOWORD(wParam); \r\n\t\t\twmEvent = HIWORD(wParam); \r\n\t\t\t// ˵ѡ\r\n\t\t\tswitch (wmId)\r\n\t\t\t{\r\n\t\t\t\tcase IDM_TEST:\r\n\t\t\t\t{\r\n\t\t\t\t\t//Test(hWnd, message, wParam, lParam);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t\tcase IDM_ABOUT:\r\n\t\t\t\t\tDialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase IDM_EXIT:\r\n\t\t\t\t\tDestroyWindow(hWnd);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase IDM_SETTINGS:\r\n\t\t\t\t\tif (IDC_ACCEPT == DialogBox(hInst, (LPCTSTR)IDD_SETTINGS, hWnd, (DLGPROC)Settings))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (g_pGlobalSetting->cust.m_bNetworkEnabled)\r\n\t\t\t\t\t\t\tg_pMainWnd->NetworkStartup();\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\tg_pMainWnd->NetworkShutdown();\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase IDM_KOCHSTART:\r\n\t\t\t\t\tif (2 > strlen(g_pGlobalSetting->cust.m_vKochChar))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tMessageBox(hWnd, \"ûKochѵַ\\nڲ˵[->]2ASCIIַ\", \"\", MB_OK);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tDialogBox(hInst, (LPCTSTR)IDD_COPYPAD, hWnd, (DLGPROC)CopyPad);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase IDM_KOCHWAVE:\r\n\t\t\t\t{\r\n\t\t\t\t\tif (2 > strlen(g_pGlobalSetting->cust.m_vKochChar))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tMessageBox(hWnd, \"ûKochѵַ\\nڲ˵[->]2ASCIIַ\", \"\", MB_OK);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tKochToWave(hWnd);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t\tcase IDM_PROMPTWAVE:\r\n\t\t\t\t{\r\n\t\t\t\t\tstrcpy(g_vPromptText, \"벻200ַȵַ: \");\r\n\t\t\t\t\tif (0 < DialogBox(hInst, (LPCTSTR)IDD_PROMPTBOX, hWnd, (DLGPROC)PromptProc))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (0 < strlen(g_vPromptBuff))\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tPromptToWave(hWnd);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t\tcase IDA_TEST:\r\n\t\t\t\t\tDialogBox(hInst, (LPCTSTR)IDD_TEST, hWnd, (DLGPROC)TestDlg);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tdefault:\r\n\t\t\t\t\treturn DefWindowProc(hWnd, message, wParam, lParam);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase WM_DESTROY:\r\n\t\t\tSAFE_DELETE(g_pMainWnd);\r\n\r\n\t\t\tPostQuitMessage(0);\r\n\t\t\tbreak;\r\n\t\tdefault:\r\n\t\t\treturn DefWindowProc(hWnd, message, wParam, lParam);\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\n// ڡϢ\r\nLRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r\n{\r\n\tswitch (message)\r\n\t{\r\n\tcase WM_INITDIALOG:\r\n\t\treturn TRUE;\r\n\r\n\tcase WM_COMMAND:\r\n\t\tif (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) \r\n\t\t{\r\n\t\t\tEndDialog(hDlg, LOWORD(wParam));\r\n\t\t\treturn TRUE;\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn FALSE;\r\n}\r\n\r\n// 1 \"PARIS\" = 1 word\r\n// .__. ._ ._. .. ...\r\n//\r\nvoid CalcSpeed(HWND hDlg)\r\n{\r\n\tif (!GetDlgItem(hDlg, IDC_SPEED))\r\n\t\treturn;\r\n\r\n\tWPMS wpms;\r\n\twpms.wdelay = g_oTmpCust.m_nWordDelay;\r\n\r\n\tGetDlgItemInt(hDlg, IDC_SHORTHIT, &wpms.di);\r\n\tGetDlgItemInt(hDlg, IDC_LONGHIT, &wpms.dah);\r\n\tGetDlgItemInt(hDlg, IDC_HITDELAY, &wpms.hdelay);\r\n\tGetDlgItemInt(hDlg, IDC_LETTERDELAY, &wpms.ldelay);\r\n\t\r\n\tparamsToWpm(&wpms);\r\n\r\n\tSetDlgItemInt(hDlg, IDC_SPEED, (UINT)wpms.wpm, TRUE);\r\n}\r\n\r\nvoid UncalcSpeed(HWND hDlg)\r\n{\r\n\tWPMS wpms;\r\n\tint wpm;\r\n\tGetDlgItemInt(hDlg, IDC_SPEED, &wpm);\r\n\tif (0 == wpm)\r\n\t\treturn;\r\n\r\n\twpms.wpm = (float)wpm;\r\n\twpmToParams(&wpms);\r\n\r\n\tSetDlgItemInt(hDlg, IDC_SHORTHIT, wpms.di, TRUE);\r\n\tSetDlgItemInt(hDlg, IDC_LONGHIT, wpms.dah, TRUE);\r\n\tSetDlgItemInt(hDlg, IDC_HITDELAY, wpms.hdelay, TRUE);\r\n\tSetDlgItemInt(hDlg, IDC_LETTERDELAY, wpms.ldelay, TRUE);\r\n\t//SetDlgItemInt(hDlg, IDC_WORDDELAY, nHitLen * 3, TRUE);\r\n\tg_oTmpCust.m_nWordDelay = wpms.wdelay;\r\n}\r\n\r\nDLGTEMPLATE * WINAPI DoLockDlgRes(LPCSTR lpszResName) \r\n{ \r\n    HRSRC hrsrc = FindResource(NULL, lpszResName, RT_DIALOG); \r\n    HGLOBAL hglb = LoadResource(hInst, hrsrc); \r\n    return (DLGTEMPLATE *) LockResource(hglb); \r\n} \r\n\r\nVOID WINAPI OnSelChanged(HWND hDlg) \r\n{\r\n\tHWND hTab = GetDlgItem(hDlg, IDC_SETTINGSTAB);\r\n    int iSel = TabCtrl_GetCurSel(hTab); \r\n \r\n\tDestroyCurrPage(hTab);\r\n\tDLGTEMPLATE* pDlgTemp = NULL;\r\n\tswitch(iSel)\r\n\t{\r\n\t\tcase 0:\r\n\t\t\tpDlgTemp = DoLockDlgRes(MAKEINTRESOURCE(IDD_GENERAL));\r\n\t\t\tbreak;\r\n\t\tcase 1:\r\n\t\t\tpDlgTemp = DoLockDlgRes(MAKEINTRESOURCE(IDD_SEND));\r\n\t\t\tbreak;\r\n\t\tcase 2:\r\n\t\t\tpDlgTemp = DoLockDlgRes(MAKEINTRESOURCE(IDD_RECV));\r\n\t\t\tbreak;\r\n\t\tcase 3:\r\n\t\t\tpDlgTemp = DoLockDlgRes(MAKEINTRESOURCE(IDD_KOCH));\r\n\t\t\tbreak;\r\n\t\tcase 4:\r\n\t\t\tpDlgTemp = DoLockDlgRes(MAKEINTRESOURCE(IDD_NETWORK));\r\n\t\t\tbreak;\r\n\t\tcase 5:\r\n\t\t\tpDlgTemp = DoLockDlgRes(MAKEINTRESOURCE(IDD_IO));\r\n\t\t\tbreak;\r\n\t}\r\n\r\n\tif (pDlgTemp)\r\n\t{\r\n\t\tHWND hCurrPage = CreateDialogIndirect(hInst, pDlgTemp, hDlg, SettingsPage);\r\n\t\tif (hCurrPage)\r\n\t\t{\r\n\t\t\tSetWindowLongPtr(hTab, GWL_USERDATA, (LONG)hCurrPage);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nBOOL OnSettingsInit(HWND hDlg)\r\n{\r\n\tg_pGlobalSetting->GetCustomize(&g_oTmpCust);\r\n\tg_oTmpHosts = g_pGlobalSetting->hosts;\r\n\t\r\n\t//g_oTmpCust = g_pGlobalSetting->cust;\r\n\r\n\tHWND hTabCtrl = GetDlgItem(hDlg, IDC_SETTINGSTAB);\r\n\tTCITEM tie;\r\n    tie.mask = TCIF_TEXT | TCIF_IMAGE; \r\n    tie.iImage = -1; \r\n    tie.pszText = \"\"; \r\n    TabCtrl_InsertItem(hTabCtrl, 0, &tie); \r\n\r\n    tie.mask = TCIF_TEXT | TCIF_IMAGE; \r\n    tie.iImage = -1; \r\n    tie.pszText = \"\"; \r\n    TabCtrl_InsertItem(hTabCtrl, 1, &tie); \r\n\r\n    tie.mask = TCIF_TEXT | TCIF_IMAGE; \r\n    tie.iImage = -1; \r\n    tie.pszText = \"\"; \r\n    TabCtrl_InsertItem(hTabCtrl, 2, &tie); \r\n\r\n    tie.mask = TCIF_TEXT | TCIF_IMAGE; \r\n    tie.iImage = -1; \r\n    tie.pszText = \"Kochѵ\"; \r\n    TabCtrl_InsertItem(hTabCtrl, 3, &tie); \r\n\r\n    tie.mask = TCIF_TEXT | TCIF_IMAGE; \r\n    tie.iImage = -1; \r\n    tie.pszText = \"\"; \r\n    TabCtrl_InsertItem(hTabCtrl, 4, &tie); \r\n\r\n    tie.mask = TCIF_TEXT | TCIF_IMAGE; \r\n    tie.iImage = -1; \r\n    tie.pszText = \"I/O\"; \r\n    TabCtrl_InsertItem(hTabCtrl, 5, &tie); \r\n\r\n\tOnSelChanged(hDlg);\r\n\treturn TRUE;\r\n}\r\n\r\nvoid HostListAdd(HWND hListCtrl, char* pHost, const char* pPort, int idx)\r\n{\r\n\tLVITEM lvi;\r\n\tlvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_PARAM;\t// | LVIF_IMAGE \r\n\tlvi.state = 0;\r\n\tlvi.stateMask = 0;\r\n\tlvi.iSubItem = 0;\r\n\tlvi.iItem = idx;\r\n\tlvi.pszText = pHost;\r\n\tlvi.lParam = (LPARAM)pPort;\r\n\tListView_InsertItem(hListCtrl, &lvi);\r\n}\r\n\r\nBOOL OnSettingPagesInit(HWND hDlg)\r\n{\r\n\tSetDlgItemDec(hDlg, IDC_BEEPFREQ, g_oTmpCust.m_rBeepFreq);\r\n\tSetDlgItemDec(hDlg, IDC_BEEPVOL, g_oTmpCust.m_rBeepVol);\r\n\tSetDlgItemInt(hDlg, IDC_SENDPERIOD, g_oTmpCust.m_nSendJournalPeriod, TRUE);\r\n\tSetDlgItemInt(hDlg, IDC_SENDILDELIMIT, g_oTmpCust.m_nSendIdleLimit, TRUE);\r\n\tSetDlgItemInt(hDlg, IDC_CW, g_oTmpCust.m_oCwKeyButton.nKeyCode, TRUE);\r\n\tSetDlgItemInt(hDlg, IDC_WORDDELAY, g_oTmpCust.m_nWordDelay, TRUE);\r\n\r\n\tSetDlgItemInt(hDlg, IDC_RECVANALYZESAMPLES, g_oTmpCust.m_nRecvAnalyzeSamples, TRUE);\r\n\tSetDlgItemInt(hDlg, IDC_RECVPERIOD, g_oTmpCust.m_nRecvJournalPeriod, TRUE);\r\n\tSetDlgItemInt(hDlg, IDC_RECVILDELIMIT, g_oTmpCust.m_nRecvIdleLimit, TRUE);\r\n\tSetDlgItemDec(hDlg, IDC_RECVTHRESHOLD, g_oTmpCust.m_rRecvThreshold);\r\n\tSetDlgItemInt(hDlg, IDC_RECVFREQSTART, g_oTmpCust.m_nRecvFreqStart, TRUE);\r\n\tSetDlgItemInt(hDlg, IDC_RECVFREQEND, g_oTmpCust.m_nRecvFreqEnd, TRUE);\r\n\r\n\tSetDlgItemInt(hDlg, IDC_SHORTHIT, g_oTmpCust.m_nShortHit, TRUE);\r\n\tSetDlgItemInt(hDlg, IDC_LONGHIT, g_oTmpCust.m_nLongHit, TRUE);\r\n\tSetDlgItemInt(hDlg, IDC_HITDELAY, g_oTmpCust.m_nHitDelay, TRUE);\r\n\tSetDlgItemInt(hDlg, IDC_LETTERDELAY, g_oTmpCust.m_nLetterDelay, TRUE);\r\n\r\n\tSetDlgItemText(hDlg, IDC_KOCHCHARS, g_oTmpCust.m_vKochChar);\r\n\tSetDlgItemInt(hDlg, IDC_KOCHWORDLEN, g_oTmpCust.m_nKochWordLen, TRUE);\r\n\r\n\tHWND hCtrl = GetDlgItem(hDlg, IDC_EXTPORTENABLE);\r\n\tif (hCtrl)\r\n\t\tSendMessage(hCtrl, BM_SETCHECK, g_oTmpCust.m_nExtPortEnable, 0);\r\n\r\n\tSetDlgItemHex(hDlg, IDC_EXTPORTADDR, g_oTmpCust.m_nExtPortAddr);\r\n\tSetDlgItemHex(hDlg, IDC_OPENBYTE, g_oTmpCust.m_nOpenByte);\r\n\tSetDlgItemHex(hDlg, IDC_CLOSEBYTE, g_oTmpCust.m_nCloseByte);\r\n\r\n\tCalcSpeed(hDlg);\r\n\r\n\tSetDlgItemInt(hDlg, IDC_LOCALPORT, g_oTmpCust.m_nLocalPort, TRUE);\r\n\tSetDlgItemInt(hDlg, IDC_HOSTPORT, g_oTmpCust.m_nLocalPort, TRUE);\r\n\r\n\tif (NULL != (hCtrl = GetDlgItem(hDlg, IDC_HOSTLIST)))\r\n\t{\r\n\t\tLRESULT nStyle = SendMessage(hCtrl, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);\r\n\t\tSendMessage(hCtrl, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, nStyle | LVS_EX_FULLROWSELECT);\r\n\t\t//DWORD nStyle = GetWindowLong(hCtrl, GWL_EXSTYLE) | LVS_EX_FULLROWSELECT;\r\n\t\t//SetWindowLong(hCtrl, GWL_EXSTYLE, nStyle);\r\n\r\n//\t\tchar szText[256];     // temporary buffer \r\n\t\tLVCOLUMN lvc; \r\n\t\tlvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT |\r\n\t\t  LVCF_SUBITEM;\r\n\r\n\t\tlvc.iSubItem = 0;\r\n\t\tlvc.pszText = \"\";\r\n\t\tlvc.cx = 180;\r\n\t\tlvc.fmt = LVCFMT_LEFT;\r\n\t\tListView_InsertColumn(hCtrl, 0, &lvc); \r\n\r\n\t\tlvc.iSubItem = 1;\r\n\t\tlvc.pszText = \"˿\";\r\n\t\tlvc.cx = 80;\r\n\t\tlvc.fmt = LVCFMT_LEFT;\r\n\t\tListView_InsertColumn(hCtrl, 1, &lvc); \r\n\r\n\t\tfor (DWORD i = 0; i < g_oTmpHosts.size(); ++i)\r\n\t\t{\r\n\t\t\tAddHost(hCtrl, &(g_oTmpHosts[i]));\r\n\t\t}\r\n\t}\r\n\r\n\tCheckDlgButton(hDlg, IDC_NWENABLED, g_oTmpCust.m_bNetworkEnabled ? BST_CHECKED : BST_UNCHECKED);\r\n\r\n\treturn TRUE;\r\n}\r\n\r\nvoid AddHost(HWND hCtrl, HOSTNODE* pNode)\r\n{ \r\n\tLVITEM lvi; \r\n\r\n\tlvi.mask = LVIF_TEXT; // | LVIF_STATE | LVIF_PARAM;\t// | LVIF_IMAGE \r\n\tlvi.state = 0;\r\n\tlvi.stateMask = 0;\r\n\tlvi.iSubItem = 0;\r\n\tlvi.iItem = ListView_GetItemCount(hCtrl);\r\n\tlvi.pszText = pNode->szHostName;\r\n\tlvi.lParam = 0; //(LPARAM)(pNode);\r\n\tListView_InsertItem(hCtrl, &lvi);\r\n\r\n\tlvi.iSubItem = 1;\r\n\tlvi.pszText = pNode->szPort;\r\n\tListView_SetItem(hCtrl, &lvi);\r\n}\r\n\r\nvoid DelHost(HWND hCtrl)\r\n{\r\n\tint nIdx = ListView_GetSelectionMark(hCtrl);\r\n\tif (0 <= nIdx)\r\n\t\tListView_DeleteItem(hCtrl, nIdx);\r\n}\r\n\r\nvoid SaveTemp(HWND hDlg)\r\n{\r\n\tGetDlgItemDec(hDlg, IDC_BEEPFREQ, &g_oTmpCust.m_rBeepFreq);\r\n\tGetDlgItemDec(hDlg, IDC_BEEPVOL, &g_oTmpCust.m_rBeepVol);\r\n\tGetDlgItemInt(hDlg, IDC_SENDPERIOD, &g_oTmpCust.m_nSendJournalPeriod);\r\n\tGetDlgItemInt(hDlg, IDC_SENDILDELIMIT, &g_oTmpCust.m_nSendIdleLimit);\r\n\tGetDlgItemInt(hDlg, IDC_CW, &g_oTmpCust.m_oCwKeyButton.nKeyCode);\r\n\tGetDlgItemInt(hDlg, IDC_WORDDELAY, &g_oTmpCust.m_nWordDelay);\r\n\r\n\tGetDlgItemInt(hDlg, IDC_RECVANALYZESAMPLES, &g_oTmpCust.m_nRecvAnalyzeSamples);\r\n\tGetDlgItemInt(hDlg, IDC_RECVPERIOD, &g_oTmpCust.m_nRecvJournalPeriod);\r\n\tGetDlgItemInt(hDlg, IDC_RECVILDELIMIT, &g_oTmpCust.m_nRecvIdleLimit);\r\n\tGetDlgItemDec(hDlg, IDC_RECVTHRESHOLD, &g_oTmpCust.m_rRecvThreshold);\r\n\tGetDlgItemInt(hDlg, IDC_RECVFREQSTART, &g_oTmpCust.m_nRecvFreqStart);\r\n\tGetDlgItemInt(hDlg, IDC_RECVFREQEND, &g_oTmpCust.m_nRecvFreqEnd);\r\n\r\n\tGetDlgItemInt(hDlg, IDC_SHORTHIT, &g_oTmpCust.m_nShortHit);\r\n\tGetDlgItemInt(hDlg, IDC_LONGHIT, &g_oTmpCust.m_nLongHit);\r\n\tGetDlgItemInt(hDlg, IDC_HITDELAY, &g_oTmpCust.m_nHitDelay);\r\n\tGetDlgItemInt(hDlg, IDC_LETTERDELAY, &g_oTmpCust.m_nLetterDelay);\r\n\r\n\tGetDlgItemTxt(hDlg, IDC_KOCHCHARS, g_oTmpCust.m_vKochChar, sizeof(g_oTmpCust.m_vKochChar) / sizeof(char));\r\n\tGetDlgItemInt(hDlg, IDC_KOCHWORDLEN, &g_oTmpCust.m_nKochWordLen);\r\n\r\n\tHWND hCtrl = GetDlgItem(hDlg, IDC_EXTPORTENABLE);\r\n\tg_oTmpCust.m_nExtPortEnable =\r\n\t\t(int)SendMessage(hCtrl, BM_GETCHECK, 0, 0);\r\n\tGetDlgItemHex(hDlg, IDC_EXTPORTADDR, &g_oTmpCust.m_nExtPortAddr);\r\n\tGetDlgItemHex(hDlg, IDC_OPENBYTE, &g_oTmpCust.m_nOpenByte);\r\n\tGetDlgItemHex(hDlg, IDC_CLOSEBYTE, &g_oTmpCust.m_nCloseByte);\r\n\r\n\thCtrl = GetDlgItem(hDlg, IDC_HOSTLIST);\r\n\tif (NULL != hCtrl)\r\n\t{\r\n\t\tint nTmp = g_oTmpCust.m_nLocalPort;\r\n\t\tGetDlgItemInt(hDlg, IDC_LOCALPORT, &nTmp);\r\n\t\tif (0 < nTmp && 65535 > nTmp)\r\n\t\t\tg_oTmpCust.m_nLocalPort = nTmp;\r\n\r\n\t\tg_oTmpHosts.resize(ListView_GetItemCount(hCtrl));\r\n\r\n\t\tfor (UINT i = 0; i < g_oTmpHosts.size(); ++i)\r\n\t\t{\r\n\t\t\tListView_GetItemText(hCtrl, i, 0, g_oTmpHosts[i].szHostName, sizeof(g_oTmpHosts[i].szHostName));\r\n\t\t\tListView_GetItemText(hCtrl, i, 1, g_oTmpHosts[i].szPort, sizeof(g_oTmpHosts[i].szPort));\r\n\t\t}\r\n\t\tg_oTmpCust.m_bNetworkEnabled = (BST_CHECKED == IsDlgButtonChecked(hDlg, IDC_NWENABLED));\r\n\t}\r\n}\r\n\r\nvoid DestroyCurrPage(HWND hTab)\r\n{\r\n\tHWND hCurrPage = (HWND)GetWindowLongPtr(hTab, GWL_USERDATA);\r\n    // Destroy the current child dialog box, if any. \r\n    if (hCurrPage)\r\n\t{\r\n\t\tSaveTemp(hCurrPage);\r\n        DestroyWindow(hCurrPage);\r\n\t\tSetWindowLong(hTab, GWL_USERDATA, (LONG)NULL);\r\n\t}\r\n}\r\n\r\nvoid OnSettingsAccept(HWND hDlg)\r\n{\r\n\tHWND hTab = GetDlgItem(hDlg, IDC_SETTINGSTAB);\r\n\tDestroyCurrPage(hTab);\r\n\tg_pGlobalSetting->SetCustomize(&g_oTmpCust);\r\n\tg_pGlobalSetting->hosts = g_oTmpHosts;\r\n\r\n\tSAFE_DELETE(g_pMainWnd);\r\n\tg_pMainWnd = new CLakeyMainWindow(g_hWnd, g_pGlobalSetting);\r\n\tg_pMainWnd->Initialize();\r\n}\r\n\r\n// áϢ\r\nLRESULT CALLBACK Settings(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r\n{\r\n\tswitch (message)\r\n\t{\r\n\t\tcase WM_INITDIALOG:\r\n\t\t{\r\n\t\t\treturn OnSettingsInit(hDlg);\r\n\t\t}\r\n\t\tcase WM_COMMAND:\r\n\t\t{\r\n\t\t\tswitch(LOWORD(wParam))\r\n\t\t\t{\r\n\t\t\t\tcase IDC_ACCEPT:\r\n\t\t\t\t{\r\n\t\t\t\t\tOnSettingsAccept(hDlg);\r\n\t\t\t\t}\r\n\t\t\t\tcase IDCANCEL:\r\n\t\t\t\t{\r\n\t\t\t\t\tEndDialog(hDlg, LOWORD(wParam));\r\n\t\t\t\t\treturn TRUE;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase WM_NOTIFY:\r\n\t\t{\r\n\t\t\tLPNMHDR lpnmhdr = (LPNMHDR)lParam;\r\n\t\t\tswitch(LOWORD(wParam))\r\n\t\t\t{\r\n\t\t\t\tcase IDC_SETTINGSTAB:\r\n\t\t\t\t{\r\n\t\t\t\t\tif (TCN_SELCHANGE == lpnmhdr->code)\r\n\t\t\t\t\t\tOnSelChanged(hDlg);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\t}\r\n\t}\r\n\treturn FALSE;\r\n}\r\n\r\nINT_PTR CALLBACK SettingsPage(HWND hPage, UINT message, WPARAM wParam, LPARAM lParam)\r\n{\r\n\tswitch (message)\r\n\t{\r\n\t\tcase WM_INITDIALOG:\r\n\t\t{\r\n\t\t\tSetWindowPos(hPage, HWND_TOP, \r\n\t\t\t\t8, 32, \r\n\t\t\t\t0, 0, SWP_NOSIZE);\r\n\t\t\treturn OnSettingPagesInit(hPage);\r\n\t\t}\r\n\t\tcase WM_COMMAND:\r\n\t\t{\r\n\t\t\tswitch(LOWORD(wParam))\r\n\t\t\t{\r\n\t\t\t\tcase IDC_CALCSPEED:\r\n\t\t\t\t{\r\n\t\t\t\t\tCalcSpeed(hPage);\r\n\t\t\t\t\treturn TRUE;\r\n\t\t\t\t}\r\n\t\t\t\tcase IDC_SPEED:\r\n\t\t\t\t{\r\n\t\t\t\t\tswitch(HIWORD(wParam))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcase EN_KILLFOCUS:\r\n\t\t\t\t\t\t\tUncalcSpeed(hPage);\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t\tcase IDC_HOSTADD:\r\n\t\t\t\t{\r\n\t\t\t\t\tHOSTNODE node;\r\n\t\t\t\t\tnode.szHostName[0] = '\\0';\r\n\t\t\t\t\tnode.szPort[0] = '\\0';\r\n\r\n\t\t\t\t\tGetDlgItemTxt(hPage, IDC_HOSTNAME, node.szHostName, sizeof(node.szHostName));\r\n\r\n\t\t\t\t\tif (0 < strlen(node.szHostName))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tint nPort;\r\n\t\t\t\t\t\tGetDlgItemInt(hPage, IDC_HOSTPORT, &nPort);\r\n\t\t\t\t\t\tif (0 < nPort && 65535 > nPort)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tsprintf(node.szPort, \"%d\", nPort);\r\n\t\t\t\t\t\t\tAddHost(GetDlgItem(hPage, IDC_HOSTLIST), &node);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tMessageBox(NULL, \"ȱ˿\", \"\", MB_OK);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tMessageBox(NULL, \"ȱIP\", \"\", MB_OK);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t\tcase IDC_HOSTDEL:\r\n\t\t\t\t{\r\n\t\t\t\t\tDelHost(GetDlgItem(hPage, IDC_HOSTLIST));\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase WM_NOTIFY:\r\n\t\t{\r\n\t\t\tLPNMHDR lpnmhdr = (LPNMHDR)lParam;\r\n\t\t\tswitch(LOWORD(wParam))\r\n\t\t\t{\r\n\t\t\t\tcase IDC_HOSTLIST:\r\n\t\t\t\t{\r\n\t\t\t\t\tswitch (lpnmhdr->code)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcase LVN_ENDLABELEDIT:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tNMLVDISPINFO* plvdi = (NMLVDISPINFO*)lParam;\r\n\t\t\t\t\t\t\tplvdi->item.mask |= LVIF_TEXT;\r\n\t\t\t\t\t\t\treturn TRUE;\r\n\t\t\t\t\t\t} // end of case LVN_ENDLABELEDIT\r\n\t\t\t\t\t\tcase LVN_BEGINLABELEDIT:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tNMLVDISPINFO* plvdi = (NMLVDISPINFO*)lParam;\r\n\t\t\t\t\t\t\tplvdi->item.mask |= LVIF_TEXT;\r\n\t\t\t\t\t\t\treturn FALSE;\r\n\t\t\t\t\t\t} // end of case LVN_ENDLABELEDIT\r\n\t\t\t\t\t} // end of switch \r\n\t\t\t\t\tbreak;\r\n\t\t\t\t} // end of case IDC_HOSTLIST\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\t} // end of case WM_NOTIFY\r\n\t}\r\n\treturn FALSE;\r\n}\r\n\r\nvoid InitKochSample()\r\n{\r\n\tint nSampleRange = (int)strlen(g_pGlobalSetting->cust.m_vKochChar);\r\n\tsrand((unsigned)time(NULL ));\r\n\r\n\tfor (int i = 0; i < MAX_KOCH_SAMPLE; ++i)\r\n\t{\r\n\t\tif (0 < (i + 1) % (g_pGlobalSetting->cust.m_nKochWordLen + 1))\r\n\t\t{\r\n\t\t\tg_vKochSample[i] = g_pGlobalSetting->cust.m_vKochChar[rand() % nSampleRange];\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tg_vKochSample[i] = ' ';\r\n\t\t}\r\n\t}\r\n}\r\n\r\n#define TIMER_ELAPSETIME\t101\r\n\r\n// Ϣ\r\nLRESULT CALLBACK CopyPad(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r\n{\r\n\tstatic BOOL bFinished = FALSE;\r\n\tstatic DWORD nTickCountStart = 0;\r\n\r\n\tswitch (message)\r\n\t{\r\n\t\tcase WM_INITDIALOG:\r\n\t\t{\r\n\t\t\tbFinished = FALSE;\r\n\t\t\tInitKochSample();\r\n\r\n\t\t\tMessageBox(hDlg, \"[ȷ][س]ʼ...\", \"׼\", MB_OK);\r\n\t\t\tg_pMainWnd->PushText(g_vKochSample, MAX_KOCH_SAMPLE, 0);\r\n\t\t\t\r\n\t\t\tSetTimer(hDlg, TIMER_ELAPSETIME, 220, NULL);\r\n\t\t\tnTickCountStart = GetTickCount();\r\n\r\n\t\t\tSendMessage(GetDlgItem(hDlg, IDC_COPYTEXT), EM_SETEVENTMASK, 0, ENM_CHANGE);\r\n\r\n\t\t\treturn TRUE;\r\n\t\t}\r\n\t\tcase WM_COMMAND:\r\n\t\t{\r\n\t\t\tswitch(LOWORD(wParam))\r\n\t\t\t{\r\n\t\t\t\tcase IDC_ACCEPT:\r\n\t\t\t\t{\r\n\t\t\t\t\tif (!bFinished)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tKillTimer(hDlg, TIMER_ELAPSETIME);\r\n\t\t\t\t\t\tg_pMainWnd->ClearQueue();\r\n/*\r\n\t\t\t\t\t\tchar vBuff[MAX_KOCH_SAMPLE * 2 + 256];\r\n\t\t\t\t\t\tmemset(vBuff, 0, sizeof(vBuff));\r\n\t\t\t\t\t\tGetDlgItemText(hDlg, IDC_COPYTEXT, g_vCopyText, MAX_KOCH_SAMPLE);\r\n\t\t\t\t\t\tg_vCopyText[MAX_KOCH_SAMPLE] = NULL;\r\n\t\t\t\t\t\tstrcpy(vBuff, g_vCopyText);\r\n\t\t\t\t\t\tstrcat(vBuff, \"\\r\\n----------------------------------------------------------------------------------\\r\\n\");\r\n\t\t\t\t\t\tstrncat(vBuff, g_vKochSample, strlen(g_vCopyText));\r\n\t\t\t\t\t\tSetDlgItemText(hDlg, IDC_COPYTEXT, vBuff);\r\n*/\r\n\t\t\t\t\t\tSetDlgItemText(hDlg, IDC_ACCEPT, \"ر\");\r\n\r\n\t\t\t\t\t\tbFinished = TRUE;\r\n/*\r\n\t\t\t\t\t\tCHARFORMAT fmt;\r\n\t\t\t\t\t\tmemset(&fmt, 0, sizeof(fmt));\r\n\t\t\t\t\t\tfmt.cbSize = sizeof(fmt);\r\n\t\t\t\t\t\tfmt.dwMask = CFM_COLOR;\r\n\t\t\t\t\t\tfmt.crTextColor = (toupper(g_vCopyText[nCopied - 1]) == g_vKochSample[nCopied - 1] ? RGB(0, 0, 0) : RGB(255, 0, 0));\r\n\r\n\t\t\t\t\t\tSendMessage((HWND)lParam, EM_SETCHARFORMAT, SCF_SELECTION, ((LPARAM)&fmt));\r\n*/\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tcase IDCANCEL:\r\n\t\t\t\t{\r\n\t\t\t\t\tKillTimer(hDlg, TIMER_ELAPSETIME);\r\n\t\t\t\t\tg_pMainWnd->ClearQueue();\r\n\t\t\t\t\tEndDialog(hDlg, LOWORD(wParam));\r\n\t\t\t\t\treturn TRUE;\r\n\t\t\t\t}\r\n\t\t\t\tcase IDC_COPYTEXT:\r\n\t\t\t\t{\r\n\t\t\t\t\tif (EN_CHANGE == HIWORD(wParam))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tg_vCopyText[MAX_KOCH_SAMPLE] = NULL;\r\n\t\t\t\t\t\tGetDlgItemTxt(hDlg, IDC_COPYTEXT, g_vCopyText, MAX_KOCH_SAMPLE);\r\n\t\t\t\t\t\tchar vBuff[20];\r\n\t\t\t\t\t\tint nCopied = (int)strlen(g_vCopyText);\r\n\t\t\t\t\t\tsprintf(vBuff, \"%d\", nCopied);\r\n\t\t\t\t\t\tSetDlgItemText(hDlg, IDC_COPIED, vBuff);\r\n\t\t\t\t\t\tint nCorrect = 0;\r\n\r\n\t\t\t\t\t\tfor (int i = 0; i < nCopied; ++i)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (toupper(g_vCopyText[i]) == g_vKochSample[i])\r\n\t\t\t\t\t\t\t\t++nCorrect;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tsprintf(vBuff, \"%d\", nCopied - nCorrect);\r\n\t\t\t\t\t\tSetDlgItemText(hDlg, IDC_INCORRECT, vBuff);\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tif (0 < nCopied)\r\n\t\t\t\t\t\t\tsprintf(vBuff, \"%2.1f%%\", 100.0f * nCorrect / nCopied);\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\tsprintf(vBuff, \"%%\");\r\n\r\n\t\t\t\t\t\tSetDlgItemText(hDlg, IDC_CORRECTPERC, vBuff);\r\n\r\n\t\t\t\t\t\tHWND hCopyText = (HWND)lParam;\r\n\t\t\t\t\t\tCHARRANGE oRange;\r\n\t\t\t\t\t\toRange.cpMin = nCopied - 1;\r\n\t\t\t\t\t\toRange.cpMax = nCopied;\r\n\t\t\t\t\t\tSendMessage(hCopyText, EM_EXSETSEL, 0, ((LPARAM)&oRange));\r\n\r\n\t\t\t\t\t\tCHARFORMAT fmt;\r\n\t\t\t\t\t\tmemset(&fmt, 0, sizeof(fmt));\r\n\t\t\t\t\t\tfmt.cbSize = sizeof(fmt);\r\n\t\t\t\t\t\tfmt.dwMask = CFM_COLOR;\r\n\t\t\t\t\t\tfmt.crTextColor = (toupper(g_vCopyText[nCopied - 1]) == g_vKochSample[nCopied - 1] ? RGB(0, 0, 0) : RGB(255, 0, 0));\r\n\t\t\t\t\t\tSendMessage(hCopyText, EM_SETCHARFORMAT, SCF_SELECTION, ((LPARAM)&fmt));\r\n\r\n\t\t\t\t\t\toRange.cpMin = oRange.cpMax;\r\n\t\t\t\t\t\tSendMessage(hCopyText, EM_EXSETSEL, 0, ((LPARAM)&oRange));\r\n\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\t}\r\n/*\t\tcase WM_NOTIFY:\r\n\t\t{\r\n\t\t\tif (IDC_COPYTEXT == wParam)\r\n\t\t\t{\r\n\t\t\t\tLPNMHDR pNMHDR = (LPNMHDR)lParam;\r\n\t\t\t\tswitch(pNMHDR->code)\r\n\t\t\t\t{\r\n\t\t\t\t\tcase EN_SELCHANGE:\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tg_vCopyText[MAX_KOCH_SAMPLE] = NULL;\r\n\t\t\t\t\t\tGetDlgItemText(hDlg, IDC_COPYTEXT, g_vCopyText, MAX_KOCH_SAMPLE);\r\n\r\n\t\t\t\t\t\tchar vBuff[20];\r\n\t\t\t\t\t\tint nCopied = (int)strlen(g_vCopyText);\r\n\t\t\t\t\t\tsprintf(vBuff, \"%d\", nCopied);\r\n\t\t\t\t\t\tSetDlgItemText(hDlg, IDC_COPIED, vBuff);\r\n\t\t\t\t\t\tint nCorrect = 0;\r\n\r\n\t\t\t\t\t\tfor (int i = 0; i < nCopied; ++i)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (toupper(g_vCopyText[i]) == g_vKochSample[i])\r\n\t\t\t\t\t\t\t\t++nCorrect;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tsprintf(vBuff, \"%d\", nCopied - nCorrect);\r\n\t\t\t\t\t\tSetDlgItemText(hDlg, IDC_INCORRECT, vBuff);\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tif (0 < nCopied)\r\n\t\t\t\t\t\t\tsprintf(vBuff, \"%2.1f%%\", 100.0f * nCorrect / nCopied);\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\tsprintf(vBuff, \"%%\");\r\n\r\n\t\t\t\t\t\tSetDlgItemText(hDlg, IDC_CORRECTPERC, vBuff);\r\n\r\n\t\t\t\t\t\tCHARFORMAT fmt;\r\n\t\t\t\t\t\tmemset(&fmt, 0, sizeof(fmt));\r\n\t\t\t\t\t\tfmt.cbSize = sizeof(fmt);\r\n\t\t\t\t\t\tfmt.dwMask = CFM_COLOR;\r\n\t\t\t\t\t\tfmt.crTextColor = (toupper(g_vCopyText[nCopied - 1]) == g_vKochSample[nCopied - 1] ? RGB(0, 0, 0) : RGB(255, 0, 0));\r\n\r\n\t\t\t\t\t\tSendMessage((HWND)lParam, EM_SETCHARFORMAT, SCF_SELECTION, ((LPARAM)&fmt));\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\t*/\r\n\t\tcase WM_TIMER:\r\n\t\t{\r\n\t\t\tif (TIMER_ELAPSETIME == wParam)\r\n\t\t\t{\r\n\t\t\t\tDWORD nTickCount = (GetTickCount() - nTickCountStart) / 1000;\r\n\t\t\t\tDWORD nSec = nTickCount % 60;\r\n\t\t\t\tDWORD nMin = (nTickCount /= 60) % 60;\r\n\t\t\t\tDWORD nHour = nTickCount / 60;\r\n\t\t\t\tchar vBuff[20];\r\n\t\t\t\tsprintf(vBuff, \"%2.2d:%2.2d:%2.2d\", nHour, nMin, nSec);\r\n\t\t\t\tSetDlgItemText(hDlg, IDC_ELAPSETIME, vBuff);\r\n\t\t\t\treturn TRUE;\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\treturn FALSE;\r\n}\r\n\r\nLRESULT CALLBACK TestDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r\n{\r\n\tswitch (message)\r\n\t{\r\n\tcase WM_INITDIALOG:\r\n\t\treturn TRUE;\r\n\r\n\tcase WM_COMMAND:\r\n\t\tif (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) \r\n\t\t{\r\n\t\t\tEndDialog(hDlg, LOWORD(wParam));\r\n\t\t\treturn TRUE;\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn FALSE;\r\n}\r\n\r\nconst char* ConvertKochPathname(char* pDest, const char* pSrc, UINT nBuffLen)\r\n{\r\n\tUINT nLen = (UINT)strlen(pSrc);\r\n\tUINT i;\r\n\tfor (i = 0; i < nBuffLen - 20 && i < nLen; ++i)\r\n\t{\r\n\t\tpDest[i] = (isalpha(pSrc[i]) ? pSrc[i] : '_');\r\n\t}\r\n\r\n\tstrcpy(pDest + i, \".wav\");\r\n\treturn pDest;\r\n}\r\n\r\nvoid PromptToWave(HWND hWnd)\r\n{\r\n\tchar vDestPathname[260];\r\n\tConvertKochPathname(vDestPathname, g_vPromptBuff, 256);\r\n\r\n\tTextToAskWave(vDestPathname, (UINT)sizeof(vDestPathname), g_vPromptBuff, (UINT)strlen(g_vPromptBuff), hWnd);\r\n}\r\n\r\nvoid KochToWave(HWND hWnd)\r\n{\r\n\tInitKochSample();\r\n\r\n\tchar vDestPathname[260];\r\n\tConvertKochPathname(vDestPathname, g_pGlobalSetting->cust.m_vKochChar, 256);\r\n\r\n\tTextToAskWave(vDestPathname, sizeof(vDestPathname), g_vKochSample, MAX_KOCH_SAMPLE, hWnd);\r\n}\r\n\r\nvoid TextToAskWave(char* pWavePathBuff, UINT nWavePathBuffSize, const char* pBuff, UINT nCount, HWND hWnd)\r\n{\r\n\tOPENFILENAME ofn;       // common dialog box structure\r\n//\tHANDLE hf;              // file handle\r\n\r\n\t// Initialize OPENFILENAME\r\n\tZeroMemory(&ofn, sizeof(OPENFILENAME));\r\n\tofn.lStructSize = sizeof(OPENFILENAME);\r\n\tofn.hwndOwner = hWnd;\r\n\tofn.lpstrFile = pWavePathBuff;\r\n\tofn.nMaxFile = nWavePathBuffSize;\r\n\tofn.lpstrFilter = \"All\\0*.*\\0Wave\\0*.wav\\0\";\r\n\tofn.nFilterIndex = 1;\r\n\tofn.lpstrFileTitle = NULL;\r\n\tofn.nMaxFileTitle = 0;\r\n\tofn.lpstrInitialDir = NULL;\r\n\tofn.Flags = OFN_PATHMUSTEXIST;\r\n\r\n\t// Display the Open dialog box. \r\n\tif (GetOpenFileName(&ofn))\r\n\t{\r\n\t\tTextToWave(ofn.lpstrFile, pBuff, nCount, 0);\r\n\t}\r\n}\r\n\r\nvoid TextToWave(const char* pPathname, const char* pTxt, UINT nTxtLen, UINT nWordLen)\r\n{\r\n\tCWaveFile oWaveFile(pPathname, 1, 8000, 16, g_pGlobalSetting->cust.m_nLongHit / 999.0f);\r\n\toWaveFile.SetFreq((float)g_pGlobalSetting->cust.m_rBeepFreq);\r\n\toWaveFile.SetVolumn((float)g_pGlobalSetting->cust.m_rBeepVol);\r\n\r\n\tfor (UINT i = 0; i < nTxtLen; ++i)\r\n\t{\r\n\t\tchar ch = pTxt[i];\r\n\t\tMORSECODE* pMorse = &(g_pGlobalSetting->cust.m_vMorseCode[MORSECODECOUNT - 1]);\r\n\t\tfor (int j = 0; j < MORSECODECOUNT; ++j)\r\n\t\t{\r\n\t\t\tMORSECODE* p = &(g_pGlobalSetting->cust.m_vMorseCode[j]);\r\n\t\t\tif (ch == p->nAscCode || ch + ('A' - 'a') == p->nAscCode)\r\n\t\t\t{\r\n\t\t\t\tpMorse = p;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif ('_' != pMorse->nAscCode)\r\n\t\t{\r\n\t\t\tint nWindow = pMorse->nMask + 1;\r\n\t\t\twhile(nWindow >>= 1)\r\n\t\t\t{\r\n\t\t\t\tint nHitCount =\r\n\t\t\t\t\tnWindow & pMorse->nMorseCode ? \r\n\t\t\t\t\t\tg_pGlobalSetting->cust.m_nShortHit : g_pGlobalSetting->cust.m_nLongHit;\r\n\r\n\t\t\t\toWaveFile.Append(nHitCount / 1000.0f);\r\n\t\t\t\toWaveFile.AppendBlank(g_pGlobalSetting->cust.m_nHitDelay / 1000.0f);\r\n\t\t\t}\r\n\r\n\t\t\toWaveFile.AppendBlank(g_pGlobalSetting->cust.m_nLetterDelay / 1000.0f);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\toWaveFile.AppendBlank(g_pGlobalSetting->cust.m_nWordDelay / 1000.0f);\r\n\t\t}\r\n\r\n\t\tif (0 < nWordLen && 0 == (i + 1) % nWordLen)\r\n\t\t\toWaveFile.AppendBlank(g_pGlobalSetting->cust.m_nWordDelay / 1000.0f);\r\n\t}\r\n}\r\n\r\nLRESULT CALLBACK PromptProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r\n{\r\n\tswitch (message)\r\n\t{\r\n\t\tcase WM_INITDIALOG:\r\n\t\t{\r\n\t\t\tSetDlgItemText(hDlg, IDC_PROMPTTEXT, g_vPromptText);\r\n\t\t\tSetDlgItemText(hDlg, IDC_INPUTSTR, g_vPromptBuff);\r\n\t\t\treturn TRUE;\r\n\t\t}\r\n\t\tcase WM_COMMAND:\r\n\t\t{\r\n\t\t\tswitch(LOWORD(wParam))\r\n\t\t\t{\r\n\t\t\t\tcase IDOK:\r\n\t\t\t\t{\r\n\t\t\t\t\tGetDlgItemTxt(hDlg, IDC_INPUTSTR, g_vPromptBuff, sizeof(g_vPromptBuff));\r\n\t\t\t\t\tEndDialog(hDlg, 1);\r\n\t\t\t\t\treturn TRUE;\r\n\t\t\t\t}\r\n\t\t\t\tcase IDCANCEL:\r\n\t\t\t\t{\r\n\t\t\t\t\tEndDialog(hDlg, 0);\r\n\t\t\t\t\treturn TRUE;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\treturn FALSE;\r\n}\r\n"
  },
  {
    "path": "src/LakeyMainWindow.cpp",
    "content": "#include \"StdAfx.h\"\r\n#include \"lakeymainwindow.h\"\r\n\r\n#include \"Mmreg.h\"\r\n#include \"dsound.h\"\r\n#include \"math.h\"\r\n#include \"stdio.h\"\r\n\r\n#include \"LakeySetting.h\"\r\n#include \"SinSound.h\"\r\n#include \"EventManagerWin32.h\"\r\n#include \"LaButton.h\"\r\n#include \"LaTuner.h\"\r\n#include \"LaJournalPanel.h\"\r\n#include \"LaLabel.h\"\r\n#include \"LaLine.h\"\r\n#include \"LaWaveCapture.h\"\r\n#include \"LaHwControl.h\"\r\n#include \"LaNetwork.h\"\r\n#include \"LaSpectrogram.h\"\r\n\r\n#include \"Resource.h\"\r\n\r\n#include <assert.h>\r\n\r\n#define SAFE_DELETE(x)\t\tif (x) { delete x; x = NULL; }\r\n#define SAFE_DELETE_DC(h)\tif (h) { DeleteDC(h); h = NULL; }\r\n#define SEND_SHORT_COUNT_EXPR\t(m_pSetting->cust.m_nLongHit * 2 / (m_pSetting->cust.m_nSendJournalPeriod * 3))\r\n#define RECV_SHORT_COUNT_EXPR\t(m_pSetting->cust.m_nShortHit * 1.5 * 44.100 / m_pSetting->cust.m_nRecvAnalyzeSamples)\r\n\r\n#define JOIN_SAFELY(ht)\t\t\t\t\t\t\t\t\\\r\n{\t\t\t\t\t\t\t\t\t\t\t\t\t\\\r\n\tif (NULL != ht)\t\t\t\t\t\t\t\t\t\\\r\n\t{\t\t\t\t\t\t\t\t\t\t\t\t\\\r\n\t\tDWORD nExitCode_j = -1;\t\t\t\t\t\t\\\r\n\t\tif (GetExitCodeThread(ht, &nExitCode_j))\t\\\r\n\t\t\tif (STILL_ACTIVE == nExitCode_j)\t\t\\\r\n\t\t\t\tWaitForSingleObject(ht, INFINITE);\t\\\r\n\t}\t\t\t\t\t\t\t\t\t\t\t\t\\\r\n}\r\n\r\nCLakeyMainWindow::CLakeyMainWindow(HWND hWnd, CLakeySetting* pSetting)\r\n: CEventDispatcherWin32(hWnd)\r\n{\r\n\tm_pSetting = pSetting;\r\n\r\n\tm_pFont = new CFont(\"Arial\", 12, CFont::THIN);\r\n\tm_pLogoFont = new CFont(\"Courier New\", 20, CFont::THIN);\r\n\tm_pLogoFont->SetItalic(TRUE);\r\n\t//m_pLogoFont->SetUnderline(TRUE);\r\n\r\n\tm_oBtStyle.nTextFormat = DT_END_ELLIPSIS|DT_LEFT;\r\n\tm_oBtStyle.pFont = m_pFont;\r\n\t\r\n\tm_oLabelStyle.nTextFormat = DT_END_ELLIPSIS|DT_LEFT;\r\n\tm_oLabelStyle.pFont = m_pFont;\r\n\tm_oLabelStyle.nBgColor = RGB(255, 255, 255);\r\n\tm_oLabelStyle.nColor = RGB(0, 0, 0);\r\n\r\n\tm_oScqlStyle.nTextFormat = DT_END_ELLIPSIS|DT_LEFT;\r\n\tm_oScqlStyle.pFont = m_pFont;\r\n\tm_oScqlStyle.nBgColor = RGB(255, 255, 255);\r\n\tm_oScqlStyle.nColor = RGB(0, 0, 0);\r\n\r\n\tm_oLogoStyle.nTextFormat = DT_END_ELLIPSIS|DT_RIGHT|DT_BOTTOM|DT_SINGLELINE;\r\n\tm_oLogoStyle.pFont = m_pLogoFont;\r\n\tm_oLogoStyle.nBgColor = RGB(255, 255, 255);\r\n\tm_oLogoStyle.nColor = RGB(32, 32, 32);\r\n\r\n\tm_oVersionStyle.nTextFormat = DT_END_ELLIPSIS|DT_RIGHT|DT_BOTTOM|DT_SINGLELINE;\r\n\tm_oVersionStyle.pFont = m_pFont;\r\n\tm_oVersionStyle.nBgColor = RGB(255, 255, 255);\r\n\tm_oVersionStyle.nColor = RGB(100, 100, 100);\r\n\r\n\tAddPaintEventControl(this);\r\n\r\n\tm_pBtCw = CreateButton(&m_pSetting->cust.m_oCwKeyButton);\r\n\tm_pBtSendPause = CreateButton(&m_pSetting->cust.m_oSendPauseButton, CLaButton::BT_LOCKABLE);\r\n\tm_pBtSendFile = CreateButton(&m_pSetting->cust.m_oSendFileButton);\r\n\tm_pBtAutoKeySwitch = CreateButton(&m_pSetting->cust.m_oAutoKeySwitchButton);\r\n\tm_pBtNoiseSwitch = CreateButton(&m_pSetting->cust.m_oNoiseSwitchButton, CLaButton::BT_LOCKABLE);\r\n\r\n\tm_pJpSend = CreateJournalPanel(&m_pSetting->cust.m_oSendJournalRect, SEND_SHORT_COUNT_EXPR, &m_oLabelStyle, this);\r\n\tm_pJpRecv = CreateJournalPanel(&m_pSetting->cust.m_oRecvJournalRect, (int)RECV_SHORT_COUNT_EXPR, &m_oLabelStyle, NULL);\r\n\tm_pRecvSpectrogram = CreateSpectrogram(&m_pSetting->cust.m_oSpectrogramRect, NULL);\r\n\tm_pRecvSpectrogram->SetBrightness(m_pSetting->cust.m_oSpecBrightnessTuner.v);\r\n\tm_pRecvSpectrogram->Initialize();\r\n\tm_pRecvDctMonitor = CreateWaveCapture(&m_pSetting->cust.m_oRecvMonitorRect, m_pRecvSpectrogram);\r\n\r\n\tm_pSendCharQueueLabel = CreateLabel(&m_pSetting->cust.m_oSendCharQueueRect, NULL, &m_oScqlStyle, \"HHH\");\r\n\tRECT r = m_pSetting->cust.m_oSendJournalRect;\r\n\tOffsetRect(&r, m_pSetting->cust.m_oSendLabelOffset.cx, m_pSetting->cust.m_oSendLabelOffset.cy);\r\n\tr.bottom = r.top + 12;\r\n\tr.right = r.left + 40;\r\n\tm_pSendLabel = CreateLabel(&r, m_pSetting->cust.m_vSendLabel, &m_oLabelStyle);\r\n\tr = m_pSetting->cust.m_oRecvJournalRect;\r\n\tOffsetRect(&r, m_pSetting->cust.m_oRecvLabelOffset.cx, m_pSetting->cust.m_oRecvLabelOffset.cy);\r\n\tr.bottom = r.top + 12;\r\n\tr.right = r.left + 40;\r\n\tm_pRecvLabel = CreateLabel(&r, m_pSetting->cust.m_vRecvLabel, &m_oLabelStyle);\r\n\r\n\tm_pSendJpBorder = CreateLine(m_pSetting->cust.m_oSendCharQueueRect.left, m_pSetting->cust.m_oSendCharQueueRect.bottom + 1,\r\n\t\t\tm_pSetting->cust.m_oSendCharQueueRect.right, m_pSetting->cust.m_oSendCharQueueRect.bottom + 1);\r\n\tm_pRecvJpBorder = CreateLine(m_pSetting->cust.m_oRecvJournalRect.left, m_pSetting->cust.m_oRecvJournalRect.bottom + 1,\r\n\t\t\tm_pSetting->cust.m_oRecvJournalRect.right, m_pSetting->cust.m_oRecvJournalRect.bottom + 1);\r\n\r\n\tm_hMorseQueueThread = NULL;\r\n\tm_nMorseQueueThreadID = 0;\r\n\tm_hMorseJournalThread = NULL;\r\n\tm_nMorseJournalThreadID = 0;\r\n\tm_hRecvMonitorThread = NULL;\r\n\tm_nRecvMonitorThreadID = 0;\r\n\r\n\tBuildMorseButtons();\r\n\r\n\tm_pTnSendVol = CreateTuner(&m_pSetting->cust.m_oSendVolTuner);\r\n\tm_pTnBgVol = CreateTuner(&m_pSetting->cust.m_oNoiseVolTuner);\r\n\tm_pTnSendSpeed = CreateTuner(&m_pSetting->cust.m_oSendSpeedTuner);\r\n\tm_pTnSpecBrightness = CreateTuner(&m_pSetting->cust.m_oSpecBrightnessTuner);\r\n\r\n\tGetRect(&r);\r\n\tr.right -= r.left;\r\n\tr.bottom -= r.top + 20;\r\n\tr.left = r.right - 80;\r\n\tr.top = r.bottom - 20;\r\n\t// m_pLogo = CreateLabel(&r, \"Lakey \", &m_oLogoStyle);\r\n\r\n\tr.top += 20;\r\n\tr.bottom += 16;\r\n\tr.right -= 10;\r\n\t// m_pVersion = CreateLabel(&r, \"b0019\", &m_oVersionStyle);\r\n\r\n\tm_pSound = new CSinSound();\r\n\tm_pSound->SetFrequency((float)m_pSetting->cust.m_rBeepFreq);\r\n\tm_pSound->SetScale((float)m_pSetting->cust.m_rBeepVol);\r\n\r\n\tm_bNeedExit = FALSE;\r\n\tm_bCwFlag = FALSE;\r\n\tm_nRecvIdleCount = 0;\r\n\tm_bPause = FALSE;\r\n\tm_bClear = FALSE;\r\n\tm_bNwSndState = FALSE;\r\n\tm_nAutoKey = 0;\r\n\tm_nEncryptTrngTotalChars = 0;\r\n\tm_hSendJrnFile = NULL;\r\n\r\n\tm_pExtPort = new CLaHwControl(m_pSetting->cust.m_nExtPortAddr, m_pSetting->cust.m_nCloseByte);\r\n\r\n\tm_pNetwork = new CLaNetwork(0);\r\n\tm_pNetwork->BindEventListener(this);\r\n\tm_pNetwork->BindFrameListener(this);\r\n\r\n\tAddCommandEventControl(this);\r\n\tAddKeyboardEventControl(this);\r\n}\r\n\r\nCLakeyMainWindow::~CLakeyMainWindow(void)\r\n{\r\n\t// save current win rect\r\n\tGetWindowRect(GetHWnd(), &m_pSetting->cust.m_oWindowRect);\r\n\r\n\tm_bNeedExit = TRUE;\r\n\tResumeThread(m_hMorseQueueThread);\r\n\tJOIN_SAFELY(m_hMorseQueueThread);\r\n\tJOIN_SAFELY(m_hMorseJournalThread);\r\n\tJOIN_SAFELY(m_hRecvMonitorThread);\r\n\r\n\tm_pSetting->cust.m_oSendVolTuner.v = this->m_pTnSendVol->GetScale();\r\n\tm_pSetting->cust.m_oNoiseVolTuner.v = this->m_pTnBgVol->GetScale();\r\n\tm_pSetting->cust.m_oSendSpeedTuner.v = this->m_pTnSendSpeed->GetScale();\r\n\tm_pSetting->cust.m_oSpecBrightnessTuner.v = this->m_pTnSpecBrightness->GetScale();\r\n\r\n\t// delete m_pVersion;\r\n\t// delete m_pLogo;\r\n\tdelete m_pTnSpecBrightness;\r\n\tdelete m_pTnSendSpeed;\r\n\tdelete m_pTnBgVol;\r\n\tdelete m_pTnSendVol;\r\n\tdelete m_pNetwork;\r\n\tdelete m_pExtPort;\r\n\tdelete m_pRecvDctMonitor;\r\n\tdelete m_pRecvJpBorder;\r\n\tdelete m_pJpRecv;\r\n\tdelete m_pSendJpBorder;\r\n\tdelete m_pSendCharQueueLabel;\r\n\tdelete m_pJpSend;\r\n\tdelete m_pBtCw;\r\n\tdelete m_pBtSendPause;\r\n\tdelete m_pBtSendFile;\r\n\tdelete m_pBtAutoKeySwitch;\r\n\tdelete m_pBtNoiseSwitch;\r\n\tdelete m_pSendLabel;\r\n\tdelete m_pRecvLabel;\r\n\tdelete m_pSound;\r\n\tdelete m_pLogoFont;\r\n\tdelete m_pFont;\r\n\tdelete m_pRecvSpectrogram;\r\n\r\n\tfor (int i = 0; i < MORSECODECOUNT; ++i)\r\n\t\tdelete m_vBtMorse[i];\r\n}\r\n\r\nvoid CLakeyMainWindow::BuildMorseButtons()\r\n{\r\n\tRECT r;\r\n\tGetWindowRect(GetHWnd(), &r);\r\n\r\n\tint x = 10;\r\n\tint oy = 300;\r\n\tint y = oy;\r\n\tint h = 12;\r\n\tint w = 58;\r\n\tint nMaxY = r.bottom - r.top - 6 * h;\r\n\tchar txt[] = { ' ', ' ', ' ', ' ', ' ', '#', '#', '#', '#', '#', '#', '\\0' };\r\n\r\n\tfor (int i = 0; i < MORSECODECOUNT; ++i)\r\n\t{\r\n\t\tMORSECODE* p = &(m_pSetting->cust.m_vMorseCode[i]);\r\n\t\ttxt[0] = p->nAscCode;\r\n\t\tint nWin = 0x0020;\r\n\t\tfor (int j = 0; j < 6; ++j, nWin >>= 1)\r\n\t\t{\r\n\t\t\tif (nWin & p->nMask)\r\n\t\t\t\ttxt[j + 5] = (nWin & p->nMorseCode ? '.' : '-');\r\n\t\t\telse\r\n\t\t\t\ttxt[j + 5] = ' ';\r\n\t\t}\r\n\r\n\t\tm_vBtMorse[i] = CreateButton(txt, x, y, w, h, p->nKeyCode);\r\n\t\tm_vBtMorse[i]->SetUserData(p);\r\n\r\n\t\tif ((y += (h + 2)) > nMaxY)\r\n\t\t{\r\n\t\t\ty = oy;\r\n\t\t\tx += (6 * w / 5);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nBOOL CLakeyMainWindow::OnTune(void* owner, LASCALE nScale)\r\n{\r\n\tif (m_pTnSendVol == owner)\r\n\t\tm_pSound->SetVolume((LONG)(nScale * 100));\r\n\telse if (m_pTnBgVol == owner)\r\n\t\tm_pSound->SetNoiseVolume((LONG)(nScale * 100));\r\n\telse if (m_pTnSendSpeed == owner)\r\n\t{\r\n\t\tWPMS wpms;\r\n\t\twpms.wpm = nScale;\r\n\t\twpmToParams(&wpms);\r\n\t\tm_pSetting->cust.m_nShortHit = wpms.di;\r\n\t\tm_pSetting->cust.m_nLongHit = wpms.dah;\r\n\t\tm_pSetting->cust.m_nHitDelay = wpms.hdelay;\r\n\t\tm_pSetting->cust.m_nLetterDelay = wpms.ldelay;\r\n\t\tm_pSetting->cust.m_nWordDelay = wpms.wdelay;\r\n\t\t\r\n\t\tm_pJpSend->SetMaxShortCount(SEND_SHORT_COUNT_EXPR);\r\n\t\tm_pJpRecv->SetMaxShortCount((int)RECV_SHORT_COUNT_EXPR);\r\n\t}\r\n\telse if (m_pTnSpecBrightness == owner)\r\n\t{\r\n\t\tm_pRecvSpectrogram->SetBrightness(nScale);\r\n\t}\r\n\telse\r\n\t\treturn FALSE;\r\n\r\n\treturn TRUE;\r\n}\r\n\r\nMORSECODE* CLakeyMainWindow::GetMorseCode(char ch)\r\n{\r\n\tfor (int i = 0; i < MORSECODECOUNT; ++i)\r\n\t{\r\n\t\tMORSECODE* p = &(m_pSetting->cust.m_vMorseCode[i]);\r\n\t\tif (ch == p->nAscCode || ch + ('A' - 'a') == p->nAscCode)\r\n\t\t\treturn p;\r\n\t}\r\n\r\n\t// '_' is default\r\n\treturn &(m_pSetting->cust.m_vMorseCode[MORSECODECOUNT - 1]);\r\n}\r\n\r\nCLaTuner* CLakeyMainWindow::CreateTuner(const TUNERMAPPING* pMapping)\r\n{\r\n\treturn CreateTuner(pMapping->vLabel, pMapping->x, pMapping->y, pMapping->w, pMapping->h, pMapping->vl, pMapping->vr, pMapping->v);\r\n}\r\n\r\nCLaTuner* CLakeyMainWindow::CreateTuner(const char* pText, int x, int y, int w, int h, LASCALE nScaleL, LASCALE nScaleR, LASCALE nScale)\r\n{\r\n\tRECT r;\r\n\tr.left = x; r.top = y; r.right = x + w; r.bottom = y + h;\r\n\r\n\tCLaTuner* pTuner = new CLaTuner(this, pText, &r, nScaleL, nScaleR, nScale, m_pFont);\r\n\r\n\tAddPaintEventControl(pTuner);\r\n\tAddMouseMoveEventControl(pTuner);\r\n\tAddMouseKeyEventControl(pTuner);\r\n//\tAddKeyboardEventControl(pButton);\r\n\tpTuner->AddMouseKeyEventListener(this);\r\n//\tpTuner->AddKeyboardEventListener(this);\r\n\tpTuner->AddTunerEventListener(this);\r\n\r\n\treturn pTuner;\r\n}\r\n\r\nCLaButton* CLakeyMainWindow::CreateButton(const char* pText, int x, int y, int w, int h, int nWantKeyCode, CLaButton::ButtonStyle nStyle)\r\n{\r\n\tRECT r;\r\n\tr.left = x; r.top = y; r.right = x + w; r.bottom = y + h;\r\n\r\n\tCLaButton* pButton = new CLaButton(this, pText, &r, nStyle, m_pFont);\r\n\tpButton->SetWantKeyCode(nWantKeyCode);\r\n\r\n\tAddPaintEventControl(pButton);\r\n\tAddMouseMoveEventControl(pButton);\r\n\tAddMouseKeyEventControl(pButton);\r\n\tAddKeyboardEventControl(pButton);\r\n\tpButton->AddMouseKeyEventListener(this);\r\n\tpButton->AddKeyboardEventListener(this);\r\n\r\n\treturn pButton;\r\n}\r\n\r\nCLaButton* CLakeyMainWindow::CreateButton(const BUTTONMAPPING* pMapping, CLaButton::ButtonStyle nStyle)\r\n{\r\n\treturn CreateButton(pMapping->vLabel, pMapping->x, pMapping->y, pMapping->w, pMapping->h, pMapping->nKeyCode, nStyle);\r\n}\r\n\r\nCLaJournalPanel* CLakeyMainWindow::CreateJournalPanel(const RECT* pRect, int nMaxShortCount\r\n\t, STYLE* pStyle, IParseEventListener* pParseListener)\r\n{\r\n\tCLaJournalPanel* jp = new CLaJournalPanel(this, pRect, m_pSetting->cust.m_vMorseCode, nMaxShortCount, pStyle, pParseListener);\r\n\r\n\tAddPaintEventControl(jp);\r\n\r\n\treturn jp;\r\n}\r\n\r\nCLaWaveCapture* CLakeyMainWindow::CreateWaveCapture(const RECT* pRect, IFilterDFT<short int, float>* pNextFilter)\r\n{\r\n\tCLaWaveCapture* wc = new CLaWaveCapture(this, pRect, 44100, m_pSetting->cust.m_nRecvAnalyzeSamples, pNextFilter, this);\r\n\twc->SetFreqRange(m_pSetting->cust.m_nRecvFreqStart, m_pSetting->cust.m_nRecvFreqEnd);\r\n\twc->SetThresholdLevel(m_pSetting->cust.m_rRecvThreshold);\r\n\r\n\tAddPaintEventControl(wc);\r\n\tAddMouseKeyEventControl(wc);\r\n\r\n\treturn wc;\r\n}\r\n\r\nCLaSpectrogram* CLakeyMainWindow::CreateSpectrogram(const RECT* pRect, IFilterDFT<short int, float>* pNextFilter)\r\n{\r\n\tCLaSpectrogram* p_spectrogram = new CLaSpectrogram(this, pRect, 44100, m_pSetting->cust.m_nRecvAnalyzeSamples);\r\n\r\n\tAddPaintEventControl(p_spectrogram);\r\n\tAddMouseKeyEventControl(p_spectrogram);\r\n\r\n\treturn p_spectrogram;\r\n}\r\n\r\nCLaLabel* CLakeyMainWindow::CreateLabel(const RECT* pRect, const char* pText, STYLE* pStyle, const char* pMutexName/* = NULL */)\r\n{\r\n\tCLaLabel* label = new CLaLabel(this, pRect, pText, pStyle, pMutexName);\r\n\r\n\tAddPaintEventControl(label);\r\n\r\n\treturn label;\r\n}\r\n\r\nCLaLine* CLakeyMainWindow::CreateLine(int x1, int y1, int x2, int y2)\r\n{\r\n\tCLaLine* line = new CLaLine(this, x1, y1, x2, y2);\r\n\r\n\tAddPaintEventControl(line);\r\n\r\n\treturn line;\r\n}\r\n\r\nBOOL CLakeyMainWindow::Initialize()\r\n{\r\n\tm_hMorseQueueThread = CreateThread(NULL, 0, MorseQueueThreadProc, this, CREATE_SUSPENDED, &m_nMorseQueueThreadID);\r\n\tif (!m_hMorseQueueThread)\r\n\t\treturn FALSE;\r\n\r\n\tm_hMorseJournalThread = CreateThread(NULL, 0, MorseJournalThreadProc, this, 0, &m_nMorseJournalThreadID);\r\n\tif (!m_hMorseJournalThread)\r\n\t\treturn FALSE;\r\n\r\n\t///*\r\n\tm_pRecvDctMonitor->Initialize();\r\n\tm_hRecvMonitorThread = CreateThread(NULL, 0, RecvMonitorThreadProc, this, 0, &m_nRecvMonitorThreadID);\r\n\tif (!m_hRecvMonitorThread)\r\n\t\treturn FALSE;\r\n\t//\t*/\r\n\r\n\tif (!m_pSound->Initialize(GetHWnd()))\r\n\t\treturn FALSE;\r\n\r\n\tm_pSound->SetVolume((LONG)(m_pTnSendVol->GetScale() * 100));\r\n\tm_pSound->SetNoiseVolume((LONG)(m_pTnBgVol->GetScale() * 100));\r\n\r\n\tAddTimerEventControl(m_pSound, 1, 500);\r\n\r\n\treturn TRUE;\r\n}\r\n\r\nvoid CLakeyMainWindow::GetRect(RECT* r)\r\n{\r\n\tGetClientRect(GetHWnd(), r);\r\n}\r\n\r\nBOOL CLakeyMainWindow::OnPaint(void* owner, CGraphics* g, const RECT* pRect)\r\n{\r\n\t//g->SetBgColor(RGB(127,127,127));\r\n\t//g->DrawRect(pRect);\r\n\treturn TRUE;\r\n}\r\n\r\nBOOL CLakeyMainWindow::OnMouseMove(void* owner, int x, int y)\r\n{\r\n\treturn FALSE;\r\n}\r\n\r\nBOOL CLakeyMainWindow::OnKeyDown(void* owner, int nKeyCode)\r\n{\r\n\tif (m_pBtCw == owner)\r\n\t{\r\n\t\tCwDown();\r\n\t\treturn TRUE;\r\n\t}\r\n\t/*else if (' ' == nKeyCode)\r\n\t{\r\n\t\tm_pRecvDctMonitor->Refresh();\r\n\t\treturn TRUE;\r\n\t}*/\r\n\t\r\n\treturn FALSE;\r\n}\r\n\r\nBOOL CLakeyMainWindow::OnKeyUp(void* owner, int nKeyCode)\r\n{\r\n\tif (m_pBtCw == owner)\r\n\t{\r\n\t\tCwUp();\r\n\t\treturn TRUE;\r\n\t}\r\n\telse if (m_pBtSendFile == owner)\r\n\t{\r\n\t\tChooseSendFile();\r\n\t\treturn TRUE;\r\n\t}\r\n\telse if (VK_PAUSE == nKeyCode)\r\n\t{\r\n\t\tm_pRecvDctMonitor->SetFrazeState(!m_pRecvDctMonitor->GetFrazeState());\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nBOOL CLakeyMainWindow::OnMouseKeyDown(void* owner, MouseKeyType nMkt, int x, int y)\r\n{\r\n\tif (m_pBtCw == owner)\r\n\t{\r\n\t\tif (m_nAutoKey)\r\n\t\t{\r\n\t\t\tm_nAutoKeyState = (m_nAutoKey == nMkt);\r\n\t\t\tm_oAutoKeyQueue.push(m_nAutoKeyState);\r\n\t\t\tResumeThread(m_hMorseQueueThread);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tCwDown();\r\n\t\t}\r\n\r\n\t\treturn FALSE;\r\n\t}\r\n\telse if (this == owner)\r\n\t{\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nBOOL CLakeyMainWindow::OnMouseKeyUp(void* owner, MouseKeyType nMkt, int x, int y)\r\n{\r\n\tif (m_pBtCw == owner)\r\n\t{\r\n\t\tif (m_nAutoKey)\r\n\t\t{\r\n\t\t\tm_nAutoKeyState = -1;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tCwUp();\r\n\t\t\treturn TRUE;\r\n\t\t}\r\n\t}\r\n\telse if (m_pBtSendFile == owner)\r\n\t{\r\n\t\tChooseSendFile();\r\n\t\treturn TRUE;\r\n\t}\r\n\telse if (this == owner)\r\n\t{\r\n\t}\r\n\telse\r\n\t{\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nBOOL CLakeyMainWindow::ChooseSendFile()\r\n{\r\n\tOPENFILENAME ofn;       // common dialog box structure\r\n\tchar szFile[260] = \"*.txt\";       // buffer for file name\r\n\tHANDLE hf;              // file handle\r\n\r\n\t// Initialize OPENFILENAME\r\n\tZeroMemory(&ofn, sizeof(OPENFILENAME));\r\n\tofn.lStructSize = sizeof(OPENFILENAME);\r\n\tofn.hwndOwner = GetHWnd();\r\n\tofn.lpstrFile = szFile;\r\n\tofn.nMaxFile = sizeof(szFile);\r\n\tofn.lpstrFilter = \"All\\0*.*\\0Text\\0*.TXT\\0\";\r\n\tofn.nFilterIndex = 1;\r\n\tofn.lpstrFileTitle = NULL;\r\n\tofn.nMaxFileTitle = 0;\r\n\tofn.lpstrInitialDir = NULL;\r\n\tofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;\r\n\r\n\t// Display the Open dialog box. \r\n\tif (GetOpenFileName(&ofn))\r\n\t{\r\n\t\thf = CreateFile(ofn.lpstrFile, GENERIC_READ,\r\n\t\t\t0, (LPSECURITY_ATTRIBUTES) NULL,\r\n\t\t\tOPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,\r\n\t\t\t(HANDLE) NULL);\r\n\r\n\t\tchar vBuff[256];\r\n\t\tint nRead = -1;\r\n\t\twhile(ReadFile(hf, vBuff, sizeof(vBuff), (LPDWORD)&nRead, NULL) && 0 < nRead)\r\n\t\t{\r\n\t\t\tPushText(vBuff, nRead, 0);\r\n\t\t}\r\n\r\n\t\tCloseHandle(hf);\r\n\t\treturn TRUE;\r\n\t}\r\n\treturn FALSE;\r\n}\r\n\r\nvoid CLakeyMainWindow::PushText(const char* pBuff, int nSize, int nWordLen)\r\n{\r\n\tfor (int i = 0; i < nSize; ++i)\r\n\t{\r\n\t\tif (m_pSendCharQueueLabel->PushChar(pBuff[i]))\r\n\t\t\tm_oSendMorseQueue.push(GetMorseCode(pBuff[i]));\r\n\r\n\t\tif (0 < nWordLen && 0 == (i + 1) % (nWordLen))\r\n\t\t{\r\n\t\t\tif (m_pSendCharQueueLabel->PushChar('_'))\r\n\t\t\t\tm_oSendMorseQueue.push(GetMorseCode(' '));\r\n\t\t}\r\n\t}\r\n\r\n\tm_nAutoKey = 0;\r\n\tm_pBtAutoKeySwitch->SetText(\"Manual\");\r\n\r\n\tResumeThread(m_hMorseQueueThread);\r\n}\r\n\r\nvoid CLakeyMainWindow::ClearQueue()\r\n{\r\n\tm_bClear = TRUE;\r\n\tResumeThread(m_hMorseQueueThread);\r\n}\r\n\r\nBOOL CLakeyMainWindow::OnClick(void* owner)\r\n{\r\n\tif (m_pBtCw == owner)\r\n\t{\r\n\t}\r\n\telse if (m_pBtSendPause == owner)\r\n\t{\r\n\t\tif (!(m_bPause = m_pBtSendPause->IsPressed()))\r\n\t\t\tResumeThread(m_hMorseQueueThread);\r\n\r\n\t\treturn TRUE;\r\n\t}\r\n\telse if (m_pBtSendFile == owner)\r\n\t{\r\n\t}\r\n\telse if (m_pBtAutoKeySwitch == owner)\r\n\t{\r\n\t\tswitch(m_nAutoKey)\r\n\t\t{\r\n\t\tcase LBUTTON:\r\n\t\t\t//m_pBtAutoKeySwitch->SetText(\"Auto(R/L)\");\r\n\t\t\tm_nAutoKey = RBUTTON;\r\n\t\t\tbreak;\r\n\t\tcase RBUTTON:\r\n\t\t\t//m_pBtAutoKeySwitch->SetText(\"Manual\");\r\n\t\t\tm_nAutoKey = 0;\r\n\t\t\tbreak;\r\n\t\tdefault:\r\n\t\t\t//m_pBtAutoKeySwitch->SetText(\"Auto(L/R)\");\r\n\t\t\tm_nAutoKey = LBUTTON;\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\treturn TRUE;\r\n\t}\r\n\telse if (m_pBtNoiseSwitch == owner)\r\n\t{\r\n\t\tm_pSound->SetNoise(m_pBtNoiseSwitch->IsPressed());\r\n\t\treturn TRUE;\r\n\t}\r\n\telse if (this == owner)\r\n\t{\r\n\t}\r\n\telse\r\n\t{\r\n\t\tCLaButton* pMorseBt = (CLaButton *)owner;\r\n\t\tMORSECODE* pMorseCode = (MORSECODE *)pMorseBt->GetUserData();\r\n\t\tif (pMorseCode && MAX_LABEL_TEXT_LEN > m_oSendMorseQueue.size())\r\n\t\t{\r\n\t\t\tif (m_pSendCharQueueLabel->PushChar(pMorseCode->nAscCode))\r\n\t\t\t{\r\n\t\t\t\tm_oSendMorseQueue.push(pMorseCode);\r\n\t\t\t\tResumeThread(m_hMorseQueueThread);\r\n\t\t\t}\r\n\r\n\t\t\treturn TRUE;\r\n\t\t}\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nvoid CLakeyMainWindow::CwDown()\r\n{\r\n\tm_pSound->Play();\r\n\tif (m_pSetting->cust.m_nExtPortEnable)\r\n\t\tm_pExtPort->OutByte(m_pSetting->cust.m_nExtPortAddr, m_pSetting->cust.m_nOpenByte);\r\n\r\n\tLANWPKGKEYFRAME frame;\r\n\tframe.nToState = 1;\r\n\tframe.nActTick = 0;\r\n\tframe.nReserved = 0;\r\n\r\n\tm_pNetwork->AppendKeyFrame(&frame);\r\n\r\n\tm_bCwFlag = TRUE;\r\n}\r\n\r\nvoid CLakeyMainWindow::CwUp()\r\n{\r\n\tm_pSound->Stop();\r\n\tif (m_pSetting->cust.m_nExtPortEnable)\r\n\t\tm_pExtPort->OutByte(m_pSetting->cust.m_nExtPortAddr, m_pSetting->cust.m_nCloseByte);\r\n\r\n\tLANWPKGKEYFRAME frame;\r\n\tframe.nToState = 0;\r\n\tframe.nActTick = 0;\r\n\tframe.nReserved = 0;\r\n\r\n\tm_pNetwork->AppendKeyFrame(&frame);\r\n\r\n\tm_bCwFlag = FALSE;\r\n}\r\n\r\nvoid CLakeyMainWindow::OnCwEvent(BOOL bCwDown)\r\n{\r\n\tif (bCwDown)\r\n\t\tm_nRecvIdleCount = 0;\t\r\n\r\n\tif (m_nRecvIdleCount < m_pSetting->cust.m_nRecvIdleLimit)\r\n\t\tm_pJpRecv->Sample(bCwDown);\r\n\r\n\tm_nRecvIdleCount += (int)RECV_SHORT_COUNT_EXPR;\r\n}\r\n\r\nBOOL CLakeyMainWindow::OnCommand(void* owner, int nCommId)\r\n{\r\n\tswitch(nCommId)\r\n\t{\r\n\tcase IDM_SENDTRAINING:\r\n\t\tStartEncryptTrng();\r\n\t\treturn TRUE;\r\n\t}\r\n\treturn FALSE;\r\n}\r\n\r\nvoid CLakeyMainWindow::OnKeyFrame(const LANWPKGKEYFRAME* pFrame)\r\n{\r\n\tif (pFrame->nToState)\r\n\t{\r\n\t\tm_bNwSndState = TRUE;\r\n\t\tm_pSound->Play();\r\n\t}\r\n\telse\r\n\t{\r\n\t\tm_bNwSndState = FALSE;\r\n\t\tm_pSound->Stop();\r\n\t}\r\n}\r\n\r\nvoid CLakeyMainWindow::OnSourceFrame(const LANWPKGSRCFRAME* pFrame, const char* szDomainName)\r\n{\r\n}\r\n\r\nvoid CLakeyMainWindow::OnTextFrame(const LANWPKGTXTFRAME* pFrame)\r\n{\r\n}\r\n\r\nvoid CLakeyMainWindow::OnEvent(WORD nMsg)\r\n{\r\n\tm_pSound->Stop();\r\n}\r\n\r\nBOOL CLakeyMainWindow::NetworkStartup()\r\n{\r\n\tif (m_pSetting->cust.m_bNetworkEnabled)\r\n\t{\r\n\t\tLANWSRCNODE node;\r\n\r\n\t\tfor (UINT i = 0; i < m_pSetting->hosts.size(); ++i)\r\n\t\t{\r\n\t\t\tnode.base.nAddr = inet_addr(m_pSetting->hosts[i].szHostName);\r\n\t\t\tif (INADDR_NONE != node.base.nAddr)\r\n\t\t\t{\r\n\t\t\t\tint nTmp;\r\n\t\t\t\tsscanf(m_pSetting->hosts[i].szPort, \"%d\", &nTmp);\r\n\t\t\t\tnode.base.nPort = nTmp;\r\n\t\t\t\tm_pNetwork->AppendStbSrcNode(&node);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (!m_pNetwork->Startup(m_pSetting->cust.m_nLocalPort))\r\n\t\t{\r\n\t\t\tMessageBox(NULL, \"޷繦\", \"\", MB_OK);\r\n\t\t\treturn FALSE;\r\n\t\t}\r\n\r\n\t\treturn TRUE;\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nBOOL CLakeyMainWindow::StartEncryptTrng()\r\n{\r\n\tOPENFILENAME ofn;       // common dialog box structure\r\n\tchar szFn[512] = \"*.txt\";       // buffer for file name\r\n\tHANDLE hf;              // file handle\r\n\r\n\t// Initialize OPENFILENAME\r\n\tZeroMemory(&ofn, sizeof(OPENFILENAME));\r\n\tofn.lStructSize = sizeof(OPENFILENAME);\r\n\tofn.hwndOwner = GetHWnd();\r\n\tofn.lpstrFile = szFn;\r\n\tofn.nMaxFile = sizeof(szFn) - 10;\t// reserved for postfix of journal file\r\n\tofn.lpstrFilter = \"All\\0*.*\\0Text\\0*.TXT\\0\";\r\n\tofn.nFilterIndex = 1;\r\n\tofn.lpstrFileTitle = NULL;\r\n\tofn.nMaxFileTitle = 0;\r\n\tofn.lpstrInitialDir = NULL;\r\n\tofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;\r\n\r\n\t// Display the Open dialog box. \r\n\tif (GetOpenFileName(&ofn))\r\n\t{\r\n\t\tm_nEncryptTrngOkChars = 0;\r\n\t\tm_rEncryptTrngOkStdWords = 0;\r\n\t\tm_rEncryptTrngStdWords = 0;\r\n\r\n\t\thf = CreateFile(ofn.lpstrFile, GENERIC_READ,\r\n\t\t\t0, (LPSECURITY_ATTRIBUTES) NULL,\r\n\t\t\tOPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,\r\n\t\t\t(HANDLE) NULL);\r\n\r\n\t\tint nRead = -1;\r\n\t\tchar szBuf[256];\r\n\t\twhile(ReadFile(hf, szBuf, sizeof(szBuf), (LPDWORD)&nRead, NULL) && 0 < nRead)\r\n\t\t{\r\n\t\t\tPushEncryptTrngText(szBuf, nRead);\r\n\t\t}\r\n\r\n\t\tCloseHandle(hf);\r\n\r\n\t\tif (0 == m_nEncryptTrngTotalChars)\r\n\t\t\treturn FALSE;\r\n\r\n\t\tstrcat(szFn, \".jrn\");\r\n\t\tm_hSendJrnFile = CreateFile(szFn,     // file to create\r\n                   GENERIC_WRITE | GENERIC_READ,          // open for writing\r\n                   0,                      // do not share\r\n                   NULL,                   // default security\r\n                   CREATE_ALWAYS,          // overwrite existing\r\n                   FILE_ATTRIBUTE_NORMAL,\r\n                   NULL);                  // no attr. template\r\n\r\n\t\tif (INVALID_HANDLE_VALUE == m_hSendJrnFile)\r\n\t\t{\r\n\t\t    printf(\"Could not create journal file (error %d)\\n\", GetLastError());\r\n\t\t}\r\n\r\n\t\tm_nEncryptTrngStartTC = GetTickCount();\r\n\r\n\t\treturn TRUE;\r\n\t}\r\n\treturn FALSE;\r\n\r\n}\r\nvoid CLakeyMainWindow::PushEncryptTrngText(const char* pText, int nSize)\r\n{\r\n\tfor (int i = 0; i < nSize; ++i)\r\n\t{\r\n\t\tswitch(pText[i])\r\n\t\t{\r\n\t\tcase '\\n':\r\n\t\tcase '\\r':\r\n\t\tcase '\\t':\r\n\t\tcase ' ':\r\n\t\t\tbreak;\r\n\t\tdefault:\r\n\t\t\tm_oEncryptTrngQueue.push(pText[i]);\r\n\t\t\t++m_nEncryptTrngTotalChars;\r\n\t\t}\r\n\t}\r\n}\r\nvoid CLakeyMainWindow::OnWorkOut(void* owner, const MORSECODE* pResult)\r\n{\r\n\tif (m_nEncryptTrngTotalChars)\r\n\t{\r\n\t\tif (!m_oEncryptTrngQueue.empty())\r\n\t\t{\r\n\t\t\tchar ch = m_oEncryptTrngQueue.front();\r\n\t\t\tm_oEncryptTrngQueue.pop();\r\n\r\n\t\t\tif (pResult && (ch > 'Z' ? ch - 'a' + 'A' : ch) == pResult->nAscCode)\r\n\t\t\t{\r\n\t\t\t\t++m_nEncryptTrngOkChars;\r\n\t\t\t\tm_rEncryptTrngOkStdWords += pResult->rStdWordLen;\r\n\t\t\t}\r\n\r\n\t\t\tm_rEncryptTrngStdWords += pResult->rStdWordLen;\r\n\t\t}\r\n\r\n\t\tDWORD t;\r\n\t\tif (pResult)\r\n\t\t{\r\n\t\t\tif (!WriteFile(m_hSendJrnFile, &pResult->nAscCode, 1, &t, NULL))\r\n\t\t\t{\r\n\t\t\t\tprintf(\"Could not write journal file (error %d)\\n\", GetLastError());\r\n\t\t\t}\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tWriteFile(m_hSendJrnFile, \"#\", 1, &t, NULL);\r\n\t\t}\r\n\t\t\r\n\t\tif (m_oEncryptTrngQueue.empty())\r\n\t\t{\r\n\t\t\tchar szBuf[128];\r\n\t\t\tfloat t2 = (GetTickCount() - m_nEncryptTrngStartTC) / 1000.0f;\r\n\t\t\tsprintf(szBuf\r\n\t\t\t\t, \"\\nʱ:\\t%2.1f\\nӦķַ:\\t%d\\nȷ:\\t%2.1f%%\\nƽ׼:\\t%2.1fwpm\\nȷ׼:\\t%2.1fwpm\\n(ͳƲո)\"\r\n\t\t\t\t, t2\r\n\t\t\t\t, m_nEncryptTrngTotalChars\r\n\t\t\t\t, m_nEncryptTrngOkChars * 100.0f / m_nEncryptTrngTotalChars\r\n\t\t\t\t, m_rEncryptTrngStdWords / (t2 / 60.0f)\r\n\t\t\t\t, m_rEncryptTrngOkStdWords / (t2 / 60.0f)\r\n\t\t\t);\r\n\r\n\t\t\tWriteFile(m_hSendJrnFile, \"\\n====================\", 16, &t, NULL);\r\n\t\t\tWriteFile(m_hSendJrnFile, szBuf, strlen(szBuf), &t, NULL);\r\n\t\t\tCloseHandle(m_hSendJrnFile);\r\n\r\n\t\t\tMessageBox(GetHWnd(), szBuf, \"ͳ\", MB_OK);\r\n\t\t\tm_nEncryptTrngTotalChars = 0;\r\n\t\t}\r\n\t}\r\n}\r\nvoid CLakeyMainWindow::StopEncryptTrng()\r\n{\r\n\twhile(m_oEncryptTrngQueue.empty())\r\n\t{\r\n\t\tm_oEncryptTrngQueue.pop();\r\n\t}\r\n\r\n\tm_nEncryptTrngTotalChars = 0;\r\n\tCloseHandle(m_hSendJrnFile);\r\n}\r\n\r\n// Threads definition\r\n#define NOTEVALIFNEEDEXIT(expr)\tif (!owner->m_bNeedExit) expr\r\n\r\nDWORD WINAPI CLakeyMainWindow::MorseQueueThreadProc(LPVOID pOwner)\r\n{\r\n\tCLakeyMainWindow* owner = (CLakeyMainWindow *)pOwner;\r\n\r\n\twhile(!owner->m_bNeedExit)\r\n\t{\r\n\t\t//assert(!owner->m_oSendMorseQueue.empty());\r\n\r\n\t\t// need not exit and queue not empty and not pause and not in auto key mode\r\n\t\t// send chars mode\r\n\t\twhile(!owner->m_bNeedExit && !owner->m_oSendMorseQueue.empty() && !owner->m_bPause && 0 == owner->m_nAutoKey)\r\n\t\t{\r\n\t\t\tMORSECODE* pMorse = owner->m_oSendMorseQueue.front();\r\n\t\t\towner->m_oSendMorseQueue.pop();\r\n\t\t\t\r\n\t\t\tif (!owner->m_bClear)\r\n\t\t\t{\r\n\t\t\t\tif ('_' != pMorse->nAscCode)\r\n\t\t\t\t{\r\n\t\t\t\t\tint nWindow = pMorse->nMask + 1;\r\n\t\t\t\t\twhile((!owner->m_bNeedExit) && (nWindow >>= 1))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tint nHitCount =\r\n\t\t\t\t\t\t\tnWindow & pMorse->nMorseCode ? \r\n\t\t\t\t\t\t\t\towner->m_pSetting->cust.m_nShortHit : owner->m_pSetting->cust.m_nLongHit;\r\n\r\n\t\t\t\t\t\towner->CwDown();\r\n\t\t\t\t\t\tNOTEVALIFNEEDEXIT(Sleep(nHitCount));\r\n\t\t\t\t\t\towner->CwUp();\r\n\t\t\t\t\t\tNOTEVALIFNEEDEXIT(Sleep(owner->m_pSetting->cust.m_nHitDelay));\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tNOTEVALIFNEEDEXIT(Sleep(owner->m_pSetting->cust.m_nWordDelay));\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\towner->m_pSendCharQueueLabel->PopChar();\r\n\r\n\t\t\tif (!owner->m_bClear)\r\n\t\t\t\tNOTEVALIFNEEDEXIT(Sleep(owner->m_pSetting->cust.m_nLetterDelay));\r\n\t\t}\r\n\r\n\t\t// auto key mode\r\n\t\twhile(!owner->m_bNeedExit && !owner->m_oAutoKeyQueue.empty() && !owner->m_bPause && 0 != owner->m_nAutoKey)\r\n\t\t{\r\n\t\t\tBOOL bKey = owner->m_oAutoKeyQueue.front();\r\n\t\t\towner->m_oAutoKeyQueue.pop();\r\n\t\t\t\r\n\t\t\tint nHitCount =\r\n\t\t\t\tbKey ? \r\n\t\t\t\t\towner->m_pSetting->cust.m_nShortHit : owner->m_pSetting->cust.m_nLongHit;\r\n\r\n\t\t\towner->CwDown();\r\n\t\t\tNOTEVALIFNEEDEXIT(Sleep(nHitCount));\r\n\t\t\towner->CwUp();\r\n\t\t\tNOTEVALIFNEEDEXIT(Sleep(owner->m_pSetting->cust.m_nHitDelay));\r\n\r\n\t\t\tif (0 <= owner->m_nAutoKeyState)\r\n\t\t\t{\r\n\t\t\t\tif (owner->m_oAutoKeyQueue.empty())\r\n\t\t\t\t\towner->m_oAutoKeyQueue.push(owner->m_nAutoKeyState);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\towner->m_bClear = FALSE;\r\n\t\tNOTEVALIFNEEDEXIT(SuspendThread(owner->m_hMorseQueueThread));\r\n\t}\r\n\r\n\treturn 0;\r\n}\r\n\r\nDWORD WINAPI CLakeyMainWindow::MorseJournalThreadProc(LPVOID pOwner)\r\n{\r\n\tCLakeyMainWindow* owner = (CLakeyMainWindow *)pOwner;\r\n\tint nIdleCount = 0;\r\n\r\n\twhile(!owner->m_bNeedExit)\r\n\t{\r\n\t\tif (owner->m_bCwFlag)\r\n\t\t\tnIdleCount = 0;\r\n\r\n\t\tif (nIdleCount < owner->m_pSetting->cust.m_nSendIdleLimit)\r\n\t\t\towner->m_pJpSend->Sample(owner->m_bCwFlag);\r\n\r\n\t\tNOTEVALIFNEEDEXIT(Sleep(owner->m_pSetting->cust.m_nSendJournalPeriod));\r\n\t\tnIdleCount += owner->m_pSetting->cust.m_nSendJournalPeriod;\r\n\t}\r\n\r\n\treturn 0;\r\n}\r\n\r\nDWORD WINAPI CLakeyMainWindow::RecvMonitorThreadProc(LPVOID pOwner)\r\n{\r\n\tCLakeyMainWindow* owner = (CLakeyMainWindow *)pOwner;\r\n\tint nIdleCount = 0;\r\n\r\n\twhile(!owner->m_bNeedExit)\r\n\t{\r\n\t\towner->m_pRecvDctMonitor->Refresh();\r\n\r\n\t\tif (owner->m_bNwSndState)\r\n\t\t\tnIdleCount = 0;\r\n\r\n\t\tif (nIdleCount < owner->m_pSetting->cust.m_nRecvIdleLimit)\r\n\t\t\towner->m_pJpRecv->Sample(owner->m_bNwSndState);\r\n\r\n\t\tNOTEVALIFNEEDEXIT(Sleep(owner->m_pSetting->cust.m_nRecvJournalPeriod));\r\n\t\tnIdleCount += owner->m_pSetting->cust.m_nRecvJournalPeriod;\r\n\t}\r\n\r\n\treturn 0;\r\n}\r\n"
  },
  {
    "path": "src/LakeyMainWindow.h",
    "content": "#pragma once\r\n\r\n#include <queue>\r\n\r\n#include \"EventManagerWin32.h\"\r\n#include \"LakeySetting.h\"\r\n#include \"LaWaveCapture.h\"\r\n#include \"LaNetwork.h\"\r\n#include \"LaButton.h\"\r\n#include \"LaTuner.h\"\r\n#include \"MorseParser.h\"\r\n\r\nclass CSinSound;\r\nclass CLaButton;\r\nclass CLaJournalPanel;\r\nclass CLaWaveCapture;\r\nclass CLaSpectrogram;\r\nclass CLaLabel;\r\nclass CLaLine;\r\nclass CLaHwControl;\r\nclass CLaNetwork;\r\nclass CLaTuner;\r\n\r\nclass CLakeyMainWindow\r\n\t: public CEventDispatcherWin32\r\n\t, public IMouseMoveEventListener\r\n\t, public IKeyboardEventControl\r\n\t, public IMouseKeyEventListener\r\n\t, public IPaintEventControl\r\n\t, public ICwEventListener\r\n\t, public ICommandEventControl\r\n\t, public INetworkFrameListener\r\n\t, public INetworkEventListener\r\n\t, public ITunerEventListener\r\n\t, public IParseEventListener\r\n{\r\npublic:\r\n\tCLakeyMainWindow(HWND hWnd, CLakeySetting* pSetting);\r\n\tvirtual ~CLakeyMainWindow(void);\r\n\r\n\tvirtual BOOL Initialize();\r\n\tvirtual BOOL NetworkStartup();\r\n\tvirtual void NetworkShutdown() { return m_pNetwork->Shutdown(); };\r\n\r\n\tvirtual BOOL IsRelated(int x, int y) { return TRUE; };\r\n\tvirtual void GetRect(RECT* r);\r\n\r\n\tvirtual BOOL OnMouseMove(void* owner, int x, int y);\r\n\tvirtual BOOL OnKeyDown(void* owner, int nKeyCode);\r\n\tvirtual BOOL OnKeyUp(void* owner, int nKeyCode);\r\n\tvirtual BOOL OnMouseKeyDown(void* owner, MouseKeyType nMkt, int x, int y);\r\n\tvirtual BOOL OnMouseKeyUp(void* owner, MouseKeyType nMkt, int x, int y);\r\n\tvirtual BOOL OnClick(void* owner);\r\n\tvirtual BOOL OnPaint(void* owner, CGraphics* g, const RECT* pRect);\r\n\r\n\tvirtual BOOL OnTune(void* owner, LASCALE nScale);\r\n\r\n\tvirtual void OnCwEvent(BOOL bCwDown);\r\n\tvirtual BOOL OnCommand(void* owner, int nCommId);\r\n\r\n\tvirtual void OnKeyFrame(const LANWPKGKEYFRAME* pFrame);\r\n\tvirtual void OnSourceFrame(const LANWPKGSRCFRAME* pFrame, const char* szDomainName);\r\n\tvirtual void OnTextFrame(const LANWPKGTXTFRAME* pFrame);\r\n\tvirtual void OnEvent(WORD nMsg);\r\n\tvirtual void OnWorkOut(void* owner, const MORSECODE* pResult);\r\n\r\n\tvoid PushText(const char* pText, int nSize, int nWordLen);\r\n\tvoid ClearQueue();\r\n\r\n\tBOOL StartEncryptTrng();\r\n\tvoid PushEncryptTrngText(const char* pText, int nSize);\r\n\tvoid StopEncryptTrng();\r\n\r\nprivate:\r\n\tCLaButton* CreateButton(const char* pText, int x, int y, int w, int h, int nWantKeyCode, CLaButton::ButtonStyle nStyle = CLaButton::BT_NORMAL);\r\n\tCLaButton* CreateButton(const BUTTONMAPPING* pMapping, CLaButton::ButtonStyle nStyle = CLaButton::BT_NORMAL);\r\n\tCLaJournalPanel* CreateJournalPanel(const RECT* pRect, int nMaxShortCount, STYLE* pStyle, IParseEventListener* pParseListener);\r\n\tCLaWaveCapture* CreateWaveCapture(const RECT* pRect, IFilterDFT<short int, float>* pNextFilter);\r\n\tCLaSpectrogram* CreateSpectrogram(const RECT* pRect, IFilterDFT<short int, float>* pNextFilter);\r\n\tCLaLabel* CreateLabel(const RECT* pRect, const char* pText, STYLE* pStyle, const char* pMutexName = NULL);\r\n\tCLaLine* CreateLine(int x1, int y1, int x2, int y2);\r\n\tCLaTuner* CreateTuner(const char* pText, int x, int y, int w, int h, LASCALE nScaleL, LASCALE nScaleR, LASCALE nScale);\r\n\tCLaTuner* CreateTuner(const TUNERMAPPING* pMapping);\r\n\r\n\tMORSECODE* GetMorseCode(char ch);\r\n\tBOOL ChooseSendFile();\r\n\r\n\tvoid BuildMorseButtons();\r\n\tvoid CwDown();\r\n\tvoid CwUp();\r\n\r\nprivate:\r\n\tCLakeySetting*\tm_pSetting;\r\n\tCSinSound*\tm_pSound;\r\n\r\n\t// Resources\r\n\tCFont*\t\tm_pFont;\r\n\tCFont*\t\tm_pLogoFont;\r\n\tSTYLE\t\tm_oBtStyle;\r\n\tSTYLE\t\tm_oLabelStyle;\r\n\tSTYLE\t\tm_oScqlStyle;\r\n\tSTYLE\t\tm_oLogoStyle;\r\n\tSTYLE\t\tm_oVersionStyle;\r\n\r\n\t// Controls\r\n\tCLaButton*\tm_pBtCw;\r\n\tCLaButton*\tm_pBtSendPause;\r\n\tCLaButton*\tm_pBtSendFile;\r\n\tCLaButton*\tm_pBtAutoKeySwitch;\r\n\tCLaButton*\tm_pBtNoiseSwitch;\r\n\r\n\tCLaTuner*\tm_pTnSendVol;\r\n\tCLaTuner*\tm_pTnBgVol;\r\n\tCLaTuner*\tm_pTnSendSpeed;\r\n\tCLaTuner*\tm_pTnSpecBrightness;\r\n\r\n\tBOOL\t\tm_bPause;\r\n\tBOOL\t\tm_bClear;\r\n\tBOOL\t\tm_bNwSndState;\r\n\tint\t\t\tm_nAutoKey;\r\n\tint\t\t\tm_nAutoKeyState;\r\n\r\n\t// Morse buttons\r\n\tCLaButton*\tm_vBtMorse[MORSECODECOUNT];\r\n\r\n\t// CW journal panel\r\n\tCLaJournalPanel*\tm_pJpSend;\r\n\tCLaLabel*\t\t\tm_pSendCharQueueLabel;\r\n\tCLaLine*\t\t\tm_pSendJpBorder;\r\n\tCLaLine*\t\t\tm_pSendTunerBorder;\r\n\r\n\tCLaWaveCapture*\t\tm_pRecvDctMonitor;\r\n\tCLaSpectrogram*\t\tm_pRecvSpectrogram;\r\n\tCLaJournalPanel*\tm_pJpRecv;\r\n\tCLaLine*\t\t\tm_pRecvJpBorder;\r\n\tCLaLine*\t\t\tm_pRecvTunerBorder;\r\n\r\n\tCLaLabel*\t\t\tm_pSendLabel;\r\n\tCLaLabel*\t\t\tm_pRecvLabel;\r\n\r\n\t// CLaLabel*\t\t\tm_pLogo;\r\n\t// CLaLabel*\t\t\tm_pVersion;\r\n\r\n\t// CW Flag\r\n\tBOOL\t\tm_bCwFlag;\r\n\r\n\t// HW Control\r\n\tCLaHwControl*\t\tm_pExtPort;\r\n\r\n\t// Network\r\n\tCLaNetwork*\t\t\tm_pNetwork;\r\n\r\n\t// Send morse queue\r\n\tqueue<MORSECODE *>\tm_oSendMorseQueue;\r\n\tqueue<BOOL>\t\t\tm_oAutoKeyQueue;\r\n\tBOOL\t\tm_bNeedExit;\r\n\tHANDLE\t\tm_hMorseQueueThread;\r\n\tDWORD\t\tm_nMorseQueueThreadID;\r\n\tHANDLE\t\tm_hMorseJournalThread;\r\n\tDWORD\t\tm_nMorseJournalThreadID;\r\n\tHANDLE\t\tm_hRecvMonitorThread;\r\n\tDWORD\t\tm_nRecvMonitorThreadID;\r\n\r\n\tint\t\t\tm_nRecvIdleCount;\r\n\r\n\t// encrypt training\r\n\tqueue<char>\tm_oEncryptTrngQueue;\r\n\tDWORD\t\tm_nEncryptTrngTotalChars;\r\n\tDWORD\t\tm_nEncryptTrngOkChars;\r\n\tfloat\t\tm_rEncryptTrngStdWords;\r\n\tfloat\t\tm_rEncryptTrngOkStdWords;\r\n\tDWORD\t\tm_nEncryptTrngStartTC;\r\n\tHANDLE\t\tm_hSendJrnFile;\r\n\r\n\tstatic DWORD WINAPI MorseQueueThreadProc(LPVOID pOwner);\r\n\tstatic DWORD WINAPI MorseJournalThreadProc(LPVOID pOwner);\r\n\tstatic DWORD WINAPI RecvMonitorThreadProc(LPVOID pOwner);\r\n};\r\n"
  },
  {
    "path": "src/LakeySetting.cpp",
    "content": "#include \"StdAfx.h\"\r\n#include \"lakeysetting.h\"\r\n\r\n#include \"stdio.h\"\r\n\r\n#define SetMorseCode(s, asc, mc, mm, kc)\t\\\r\n\ts.nAscCode = (asc); s.nMorseCode = (mc); s.nMask = (mm); s.nKeyCode = (kc); s.rStdWordLen = calcStdWordLen(mc, mm);\r\n\r\n#define SetButtonMapping(s, nx, ny, nw, nh, kc, txt)\t\\\r\n\ts.x = (nx); s.y = (ny); s.w = (nw); s.h = (nh); s.nKeyCode = (kc); strncpy(s.vLabel, (txt), sizeof(s.vLabel) - 1); \r\n\r\n#define SetTunerMapping(s, nx, ny, nw, nh, nl, nr, nv, txt)\t\\\r\n\ts.x = (nx); s.y = (ny); s.w = (nw); s.h = (nh); s.vl = (nl); s.vr = (nr); s.v = (nv); strncpy(s.vLabel, (txt), sizeof(s.vLabel) - 1); \r\n\r\nCLakeySetting::CLakeySetting(void)\r\n{\r\n\tcust.m_rBeepFreq = 1000.0;\r\n\tcust.m_rBeepVol = 0.25;\r\n\tcust.m_nShortHit = 80;\r\n\tcust.m_nLongHit = 240;\r\n\tcust.m_nHitDelay = 80;\r\n\tcust.m_nLetterDelay = 240;\r\n\tcust.m_nWordDelay = 240;\r\n\r\n\tSetRect(&cust.m_oWindowRect, 0, 0, 936, 450);\r\n\r\n\tcust.m_nSendJournalPeriod = 27;\r\n\tSetRect(&cust.m_oSendJournalRect, 5,235,490,267);\r\n\tcust.m_oSendLabelOffset.cx = 0;\r\n\tcust.m_oSendLabelOffset.cy = -15;\r\n\tcust.m_nSendIdleLimit = 750;\r\n\tSetRect(&cust.m_oSendCharQueueRect, 5,270,490,281);\r\n\tstrcpy(cust.m_vSendLabel, \"Send\");\r\n\r\n\tSetRect(&cust.m_oSpectrogramRect, 498,10,908,160);\r\n\tcust.m_oSpecLabelOffset.cx = 0;\r\n\tcust.m_oSpecLabelOffset.cy = -15;\r\n\tstrcpy(cust.m_vSpecLabel, \"Spectrogram\");\r\n\r\n\tcust.m_nRecvJournalPeriod = 27;\r\n\tSetRect(&cust.m_oRecvJournalRect, 5,180,490,212);\r\n\tcust.m_oRecvLabelOffset.cx = 0;\r\n\tcust.m_oRecvLabelOffset.cy = -15;\r\n\tcust.m_nRecvIdleLimit = 750;\r\n\tstrcpy(cust.m_vRecvLabel, \"Recieve\");\r\n\r\n\tSetRect(&cust.m_oRecvMonitorRect, 8,10,493,160);\r\n\tcust.m_nRecvAnalyzeSamples = 512;\r\n\tcust.m_rRecvThreshold = 0.3l;\r\n\tcust.m_nRecvFreqStart = 850;\r\n\tcust.m_nRecvFreqEnd = 1250;\r\n\r\n\tSetButtonMapping(cust.m_oCwKeyButton, 500,290,400,92, VK_RETURN, \"CW\");\r\n\tSetButtonMapping(cust.m_oSendFileButton, 500,265,91,16, VK_F6, \"File...\");\r\n\tSetButtonMapping(cust.m_oSendPauseButton, 603,265,91,16, VK_F5, \"Pause,Continue\");\r\n\tSetButtonMapping(cust.m_oAutoKeySwitchButton, 706,265,91,16, VK_TAB, \"Manual,Auto(L/R),Auto(R/L)\");\r\n\tSetButtonMapping(cust.m_oNoiseSwitchButton, 809,265,91,16, VK_F7, \"Disturb\");\r\n\r\n\tSetTunerMapping(cust.m_oSendVolTuner, 500,168,90,90,-80.000000,0.000000, 0, \"Volumn(dB)\");\r\n\tSetTunerMapping(cust.m_oSendSpeedTuner, 603,168,90,90,5.000000,30.000000, 20, \"Speed(wpm)\");\r\n\tSetTunerMapping(cust.m_oSpecBrightnessTuner, 706,168,90,90,-60.000000,60.000000, 0.0, \"Spectrogram(dB)\");\r\n\tSetTunerMapping(cust.m_oNoiseVolTuner, 809,168,90,90,-80.000000,0.000000, 0, \"Disturb(dB)\");\r\n\t\r\n\tSetMorseCode(cust.m_vMorseCode[0], 'A', 0x0002, 0x0003, 'A');\r\n\tSetMorseCode(cust.m_vMorseCode[1], 'B', 0x0007, 0x000f, 'B');\r\n\tSetMorseCode(cust.m_vMorseCode[2], 'C', 0x0005, 0x000f, 'C');\r\n\tSetMorseCode(cust.m_vMorseCode[3], 'D', 0x0003, 0x0007, 'D');\r\n\tSetMorseCode(cust.m_vMorseCode[4], 'E', 0x0001, 0x0001, 'E');\r\n\tSetMorseCode(cust.m_vMorseCode[5], 'F', 0x000d, 0x000f, 'F');\r\n\tSetMorseCode(cust.m_vMorseCode[6], 'G', 0x0001, 0x0007, 'G');\r\n\tSetMorseCode(cust.m_vMorseCode[7], 'H', 0x000f, 0x000f, 'H');\r\n\tSetMorseCode(cust.m_vMorseCode[8], 'I', 0x0003, 0x0003, 'I');\r\n\tSetMorseCode(cust.m_vMorseCode[9], 'J', 0x0008, 0x000f, 'J');\r\n\tSetMorseCode(cust.m_vMorseCode[10], 'K', 0x0002, 0x0007, 'K');\r\n\tSetMorseCode(cust.m_vMorseCode[11], 'L', 0x000b, 0x000f, 'L');\r\n\tSetMorseCode(cust.m_vMorseCode[12], 'M', 0x0000, 0x0003, 'M');\r\n\tSetMorseCode(cust.m_vMorseCode[13], 'N', 0x0001, 0x0003, 'N');\r\n\tSetMorseCode(cust.m_vMorseCode[14], 'O', 0x0000, 0x0007, 'O');\r\n\tSetMorseCode(cust.m_vMorseCode[15], 'P', 0x0009, 0x000f, 'P');\r\n\tSetMorseCode(cust.m_vMorseCode[16], 'Q', 0x0002, 0x000f, 'Q');\r\n\tSetMorseCode(cust.m_vMorseCode[17], 'R', 0x0005, 0x0007, 'R');\r\n\tSetMorseCode(cust.m_vMorseCode[18], 'S', 0x0007, 0x0007, 'S');\r\n\tSetMorseCode(cust.m_vMorseCode[19], 'T', 0x0000, 0x0001, 'T');\r\n\tSetMorseCode(cust.m_vMorseCode[20], 'U', 0x0006, 0x0007, 'U');\r\n\tSetMorseCode(cust.m_vMorseCode[21], 'V', 0x000e, 0x000f, 'V');\r\n\tSetMorseCode(cust.m_vMorseCode[22], 'W', 0x0004, 0x0007, 'W');\r\n\tSetMorseCode(cust.m_vMorseCode[23], 'X', 0x0006, 0x000f, 'X');\r\n\tSetMorseCode(cust.m_vMorseCode[24], 'Y', 0x0004, 0x000f, 'Y');\r\n\tSetMorseCode(cust.m_vMorseCode[25], 'Z', 0x0003, 0x000f, 'Z');\r\n\r\n\tSetMorseCode(cust.m_vMorseCode[26], '1', 0x0010, 0x001f, '1');\r\n\tSetMorseCode(cust.m_vMorseCode[27], '2', 0x0018, 0x001f, '2');\r\n\tSetMorseCode(cust.m_vMorseCode[28], '3', 0x001c, 0x001f, '3');\r\n\tSetMorseCode(cust.m_vMorseCode[29], '4', 0x001e, 0x001f, '4');\r\n\tSetMorseCode(cust.m_vMorseCode[30], '5', 0x001f, 0x001f, '5');\r\n\tSetMorseCode(cust.m_vMorseCode[31], '6', 0x000f, 0x001f, '6');\r\n\tSetMorseCode(cust.m_vMorseCode[32], '7', 0x0007, 0x001f, '7');\r\n\tSetMorseCode(cust.m_vMorseCode[33], '8', 0x0003, 0x001f, '8');\r\n\tSetMorseCode(cust.m_vMorseCode[34], '9', 0x0001, 0x001f, '9');\r\n\tSetMorseCode(cust.m_vMorseCode[35], '0', 0x0000, 0x001f, '0');\r\n\r\n\tSetMorseCode(cust.m_vMorseCode[36], '?', 0x0033, 0x003f, 0);\r\n\tSetMorseCode(cust.m_vMorseCode[37], '/', 0x000d, 0x001f, VK_DIVIDE);\r\n\tSetMorseCode(cust.m_vMorseCode[38], '(', 0x0012, 0x003f, 0);\r\n\tSetMorseCode(cust.m_vMorseCode[39], '-', 0x000e, 0x003f, VK_SUBTRACT);\r\n\tSetMorseCode(cust.m_vMorseCode[40], '.', 0x002a, 0x003f, VK_DECIMAL);\r\n\tSetMorseCode(cust.m_vMorseCode[41], '_', 0x0000, 0x0000, ' ');\r\n\r\n\tstrcpy(cust.m_vKochChar, \"KMRSUAPTLOWI.NJEF0Y,VG5/Q9ZH38B?427C1D6X\");\r\n\tcust.m_nKochWordLen = 5;\r\n\r\n\tcust.m_nExtPortEnable = 0;\r\n\tcust.m_nExtPortAddr = 0x378;\r\n\tcust.m_nOpenByte = 0xff;\r\n\tcust.m_nCloseByte = 0x00;\r\n\r\n\tcust.m_bNetworkEnabled = TRUE;\r\n\tcust.m_nLocalPort = 3010;\r\n\r\n\tcust.m_nFaBgColor = 0x000000;\r\n\tcust.m_nFaWaveColor = 0x00ff00;\r\n\tcust.m_nFaFreqAnaColor = 0xd0d0d0;\r\n\tcust.m_nFaFloatColor = 0xf0f0f0;\r\n\r\n\tLoad();\r\n}\r\n\r\nCLakeySetting::~CLakeySetting(void)\r\n{\r\n\tSave();\r\n}\r\n\r\nvoid CLakeySetting::StrToMorseCode(int nIdx, const char* pStr)\r\n{\r\n\tsscanf(pStr, \"%8X,%8X,%4X\"\r\n\t\t, &(cust.m_vMorseCode[nIdx].nMorseCode)\r\n\t\t, &(cust.m_vMorseCode[nIdx].nMask)\r\n\t\t, &(cust.m_vMorseCode[nIdx].nKeyCode));\r\n}\r\n\r\nchar* CLakeySetting::MorseCodeToStr(char* pStr, int nIdx)\r\n{\r\n\tsprintf(pStr, \"%8.8X,%8.8X,%4.4X\"\r\n\t\t, cust.m_vMorseCode[nIdx].nMorseCode\r\n\t\t, cust.m_vMorseCode[nIdx].nMask\r\n\t\t, cust.m_vMorseCode[nIdx].nKeyCode);\r\n\r\n\treturn pStr;\r\n}\r\n\r\nvoid CLakeySetting::StrToButtonMapping(BUTTONMAPPING* pMapping, const char* pStr)\r\n{\r\n\tsscanf(pStr, \"%d,%d,%d,%d,%4X,%s\"\r\n\t\t, &(pMapping->x)\r\n\t\t, &(pMapping->y)\r\n\t\t, &(pMapping->w)\r\n\t\t, &(pMapping->h)\r\n\t\t, &(pMapping->nKeyCode)\r\n\t\t, pMapping->vLabel\r\n\t\t);\r\n}\r\n\r\nchar* CLakeySetting::ButtonMappingToStr(char* pStr, const BUTTONMAPPING* pMapping)\r\n{\r\n\tsprintf(pStr, \"%d,%d,%d,%d,%4.4X,%s\"\r\n\t\t, pMapping->x\r\n\t\t, pMapping->y\r\n\t\t, pMapping->w\r\n\t\t, pMapping->h\r\n\t\t, pMapping->nKeyCode\r\n\t\t, pMapping->vLabel\r\n\t\t);\r\n\r\n\treturn pStr;\r\n}\r\n\r\nvoid CLakeySetting::StrToTunerMapping(TUNERMAPPING* pMapping, const char* pStr)\r\n{\r\n\tsscanf(pStr, \"%d,%d,%d,%d,%f,%f,%f,%s\"\r\n\t\t, &(pMapping->x)\r\n\t\t, &(pMapping->y)\r\n\t\t, &(pMapping->w)\r\n\t\t, &(pMapping->h)\r\n\t\t, &(pMapping->vl)\r\n\t\t, &(pMapping->vr)\r\n\t\t, &(pMapping->v)\r\n\t\t, pMapping->vLabel\r\n\t\t);\r\n}\r\n\r\nchar* CLakeySetting::TunerMappingToStr(char* pStr, const TUNERMAPPING* pMapping)\r\n{\r\n\tsprintf(pStr, \"%d,%d,%d,%d,%f,%f,%f,%s\"\r\n\t\t, pMapping->x\r\n\t\t, pMapping->y\r\n\t\t, pMapping->w\r\n\t\t, pMapping->h\r\n\t\t, pMapping->vl\r\n\t\t, pMapping->vr\r\n\t\t, pMapping->v\r\n\t\t, pMapping->vLabel\r\n\t\t);\r\n\r\n\treturn pStr;\r\n}\r\n\r\n#define PROFILE_PATHNAME\t\"./lakey.ini\"\r\n#define SECTION_CW\t\t\t\"CW\"\r\n#define CW_BEEPFREQ\t\t\t\"beepfreq\"\r\n#define CW_BEEPVOL\t\t\t\"beepvol\"\r\n#define CW_SHORTHIT\t\t\t\"shorthit\"\r\n#define CW_LONGHIT\t\t\t\"longhit\"\r\n#define CW_HITDELAY\t\t\t\"hitdelay\"\r\n#define CW_LETTERDELAY\t\t\"letterdelay\"\r\n#define CW_WORDDELAY\t\t\"worddelay\"\r\n\r\n#define SECTION_GLOBAL\t\t\t\"GLOBAL\"\r\n#define GLOBAL_WINDOWRECT\t\t\"windowrect\"\r\n\r\n#define SECTION_JOURNAL\t\t\t\"JOURNAL\"\r\n#define JOURNAL_SENDPERIOD\t\t\"sendperiod\"\r\n#define JOURNAL_SENDIDLELIMIT\t\"sendidlelimit\"\r\n#define JOURNAL_SENDRECT\t\t\"sendrect\"\r\n#define JOURNAL_SENDLABELOFFSET\t\"sendlabeloffset\"\r\n#define JOURNAL_SENDLABEL\t\t\"sendlabel\"\r\n#define JOURNAL_SENDQUEUERECT\t\"sendqueuerect\"\r\n\r\n#define JOURNAL_SPECRECT\t\t\"specrect\"\r\n#define JOURNAL_SPECLABELOFFSET\t\"speclabeloffset\"\r\n#define JOURNAL_SPECLABEL\t\t\"speclabel\"\r\n\r\n#define JOURNAL_RECVPERIOD\t\t\"recvperiod\"\r\n#define JOURNAL_RECVIDLELIMIT\t\"recvidlelimit\"\r\n#define JOURNAL_RECVRECT\t\t\"recvrect\"\r\n#define JOURNAL_RECVLABELOFFSET\t\"recvlabeloffset\"\r\n#define JOURNAL_RECVLABEL\t\t\"recvlabel\"\r\n#define JOURNAL_RECVMRECT\t\t\"recvmrect\"\r\n#define JOURNAL_RECVANALYZESAMPLE\t\"recvanalyzesamples\"\r\n#define JOURNAL_RECVTHRESHOLD\t\"recvthreshold\"\r\n#define JOURNAL_RECVFREQSTART\t\"recvfreqstart\"\r\n#define JOURNAL_RECVFREQEND\t\t\"recvfreqend\"\r\n\r\n#define SECTION_MORSE\t\t\"MORSE\"\r\n\r\n#define SECTION_MAINPANEL\t\"MAINPANEL\"\r\n#define MAINPANEL_CW\t\t\"cw\"\r\n#define MAINPANEL_SENDPAUSE\t\"sendpause\"\r\n#define MAINPANEL_SENDFILE\t\"sendfile\"\r\n#define MAINPANEL_AUTOKEYSWITCH\t\"autokeyswitch\"\r\n#define MAINPANEL_NOISESWITCH\t\"noiseswitch\"\r\n\r\n#define MAINPANEL_SENDVOL\t\"sendvol\"\r\n#define MAINPANEL_NOISEVOL\t\"noisevol\"\r\n#define MAINPANEL_SENDSPEED\t\"sendspeed\"\r\n#define MAINPANEL_SPECBRIGHTNESS\t\"specbrightness\"\r\n\r\n#define SECTION_KOCH\t\t\"KOCH\"\r\n#define KOCH_CHARS\t\t\t\"charlist\"\r\n#define KOCH_WORDLEN\t\t\"koch_wordlen\"\r\n\r\n#define SECTION_HWCTRL\t\t\"HWCTRL\"\r\n#define HWCTRL_ENABLEEXTPORT\t\"enableextport\"\r\n#define HWCTRL_EXTPORTADDR\t\"extportaddr\"\r\n#define HWCTRL_OPENBYTE\t\t\"openbyte\"\r\n#define HWCTRL_CLOSEBYTE\t\"closebyte\"\r\n\r\n#define SECTION_NETWORK\t\t\"NETWORK\"\r\n#define NETWORK_NWENABLED\t\"nwenabled\"\r\n#define NETWORK_LOCALPORT\t\"localport\"\r\n#define NETWORK_LOCALPORT_DEF\t3010\r\n//\r\n#define NETWORK_HOSTS\t\t\"hosts\"\r\n//Ϣǰ׺(host1, host2, host3, ...)\r\n#define NETWORK_HOSTENTRYEXPR\t\"host%d\"\r\n\r\nBOOL CLakeySetting::Load()\r\n{\r\n\tchar vBuff[64];\r\n\r\n\tcust.m_rBeepFreq = GetProfileDouble(SECTION_CW, CW_BEEPFREQ, cust.m_rBeepFreq);\r\n\tcust.m_rBeepVol = GetProfileDouble(SECTION_CW, CW_BEEPVOL, cust.m_rBeepVol);\r\n\tcust.m_nShortHit = GetProfileDec(SECTION_CW, CW_SHORTHIT, cust.m_nShortHit);\r\n\tcust.m_nLongHit = GetProfileDec(SECTION_CW, CW_LONGHIT, cust.m_nLongHit);\r\n\tcust.m_nHitDelay = GetProfileDec(SECTION_CW, CW_HITDELAY, cust.m_nHitDelay);\r\n\tcust.m_nLetterDelay = GetProfileDec(SECTION_CW, CW_LETTERDELAY, cust.m_nLetterDelay);\r\n\tcust.m_nWordDelay = GetProfileDec(SECTION_CW, CW_WORDDELAY, cust.m_nWordDelay);\r\n\r\n\tGetProfileRect(SECTION_GLOBAL, GLOBAL_WINDOWRECT, &cust.m_oWindowRect);\r\n\r\n\tcust.m_nSendJournalPeriod = GetProfileDec(SECTION_JOURNAL, JOURNAL_SENDPERIOD, cust.m_nSendJournalPeriod);\r\n\tcust.m_nSendIdleLimit = GetProfileDec(SECTION_JOURNAL, JOURNAL_SENDIDLELIMIT, cust.m_nSendIdleLimit);\r\n\tGetProfileRect(SECTION_JOURNAL, JOURNAL_SENDRECT, &cust.m_oSendJournalRect);\r\n\tGetProfileRect(SECTION_JOURNAL, JOURNAL_SENDQUEUERECT, &cust.m_oSendCharQueueRect);\r\n\tGetProfileSize(SECTION_JOURNAL, JOURNAL_SENDLABELOFFSET, &cust.m_oSendLabelOffset);\r\n\tGetPrivateProfileString(SECTION_JOURNAL, JOURNAL_SENDLABEL, cust.m_vSendLabel, cust.m_vSendLabel, sizeof(cust.m_vSendLabel), PROFILE_PATHNAME);\r\n\r\n\tGetProfileRect(SECTION_JOURNAL, JOURNAL_SPECRECT, &cust.m_oSpectrogramRect);\r\n\tGetProfileSize(SECTION_JOURNAL, JOURNAL_SPECLABELOFFSET, &cust.m_oSpecLabelOffset);\r\n\tGetPrivateProfileString(SECTION_JOURNAL, JOURNAL_SPECLABEL, cust.m_vSpecLabel, cust.m_vSpecLabel, sizeof(cust.m_vSpecLabel), PROFILE_PATHNAME);\r\n\r\n\tcust.m_nRecvJournalPeriod = GetProfileDec(SECTION_JOURNAL, JOURNAL_RECVPERIOD, cust.m_nRecvJournalPeriod);\r\n\tcust.m_nRecvIdleLimit = GetProfileDec(SECTION_JOURNAL, JOURNAL_RECVIDLELIMIT, cust.m_nRecvIdleLimit);\r\n\tGetProfileRect(SECTION_JOURNAL, JOURNAL_RECVRECT, &cust.m_oRecvJournalRect);\r\n\tGetProfileSize(SECTION_JOURNAL, JOURNAL_RECVLABELOFFSET, &cust.m_oRecvLabelOffset);\r\n\tGetPrivateProfileString(SECTION_JOURNAL, JOURNAL_RECVLABEL, cust.m_vRecvLabel, cust.m_vRecvLabel, sizeof(cust.m_vRecvLabel), PROFILE_PATHNAME);\r\n\tGetProfileRect(SECTION_JOURNAL, JOURNAL_RECVMRECT, &cust.m_oRecvMonitorRect);\r\n\tcust.m_nRecvAnalyzeSamples = GetProfileDec(SECTION_JOURNAL, JOURNAL_RECVANALYZESAMPLE, cust.m_nRecvAnalyzeSamples);\r\n\tcust.m_rRecvThreshold = GetProfileDouble(SECTION_JOURNAL, JOURNAL_RECVTHRESHOLD, cust.m_rRecvThreshold);\r\n\tcust.m_nRecvFreqStart = GetProfileDec(SECTION_JOURNAL, JOURNAL_RECVFREQSTART, cust.m_nRecvFreqStart);\r\n\tcust.m_nRecvFreqEnd = GetProfileDec(SECTION_JOURNAL, JOURNAL_RECVFREQEND, cust.m_nRecvFreqEnd);\r\n\r\n\tGetButtonMapping(SECTION_MAINPANEL, MAINPANEL_CW, &cust.m_oCwKeyButton);\r\n\tGetButtonMapping(SECTION_MAINPANEL, MAINPANEL_SENDPAUSE, &cust.m_oSendPauseButton);\r\n\tGetButtonMapping(SECTION_MAINPANEL, MAINPANEL_SENDFILE, &cust.m_oSendFileButton);\r\n\tGetButtonMapping(SECTION_MAINPANEL, MAINPANEL_AUTOKEYSWITCH, &cust.m_oAutoKeySwitchButton);\r\n\tGetButtonMapping(SECTION_MAINPANEL, MAINPANEL_NOISESWITCH, &cust.m_oNoiseSwitchButton);\r\n\r\n\tGetTunerMapping(SECTION_MAINPANEL, MAINPANEL_SENDVOL, &cust.m_oSendVolTuner);\r\n\tGetTunerMapping(SECTION_MAINPANEL, MAINPANEL_NOISEVOL, &cust.m_oNoiseVolTuner);\r\n\tGetTunerMapping(SECTION_MAINPANEL, MAINPANEL_SENDSPEED, &cust.m_oSendSpeedTuner);\r\n\tGetTunerMapping(SECTION_MAINPANEL, MAINPANEL_SPECBRIGHTNESS, &cust.m_oSpecBrightnessTuner);\r\n\r\n\tGetPrivateProfileString(SECTION_KOCH, KOCH_CHARS, \"\", cust.m_vKochChar, sizeof(cust.m_vKochChar), PROFILE_PATHNAME);\r\n\tcust.m_nKochWordLen = GetProfileDec(SECTION_KOCH, KOCH_WORDLEN, cust.m_nKochWordLen);\r\n\r\n\tfor (int i = 0; i < MORSECODECOUNT; ++i)\r\n\t{\r\n\t\tchar vMorseKey[2] = {' ', '\\0'};\r\n\t\tvMorseKey[0] = (char)cust.m_vMorseCode[i].nAscCode;\r\n\t\tGetPrivateProfileString(SECTION_MORSE, vMorseKey, \"\", vBuff, sizeof(vBuff), PROFILE_PATHNAME);\r\n\t\tif (strlen(vBuff))\r\n\t\t\tStrToMorseCode(i, vBuff);\r\n\t}\r\n\r\n\tcust.m_nExtPortEnable = GetProfileHex(SECTION_HWCTRL, HWCTRL_ENABLEEXTPORT, cust.m_nExtPortEnable);\r\n\tcust.m_nExtPortAddr = GetProfileHex(SECTION_HWCTRL, HWCTRL_EXTPORTADDR, cust.m_nExtPortAddr);\r\n\tcust.m_nOpenByte = GetProfileHex(SECTION_HWCTRL, HWCTRL_OPENBYTE, cust.m_nOpenByte);\r\n\tcust.m_nCloseByte = GetProfileHex(SECTION_HWCTRL, HWCTRL_CLOSEBYTE, cust.m_nCloseByte);\r\n\r\n\tcust.m_bNetworkEnabled = (0 == GetProfileDec(SECTION_NETWORK, NETWORK_NWENABLED, cust.m_bNetworkEnabled) ? FALSE : TRUE);\r\n\tcust.m_nLocalPort = GetProfileDec(SECTION_NETWORK, NETWORK_LOCALPORT, cust.m_nLocalPort);\r\n\tint nHosts = GetProfileDec(SECTION_NETWORK, NETWORK_HOSTS, 0);\r\n//\tif (HOSTS_MAX < cust.m_nHosts)\r\n//\t\tcust.m_nHosts = HOSTS_MAX;\r\n\thosts.resize(nHosts);\r\n\r\n\tfor (int i = 0; i < nHosts; ++i)\r\n\t{\r\n\t\tsprintf(vBuff, NETWORK_HOSTENTRYEXPR, i + 1);\r\n\t\tGetPrivateProfileString(SECTION_NETWORK, vBuff, \"\", vBuff, sizeof(vBuff), PROFILE_PATHNAME);\r\n\t\tchar* pSpliter = strstr(vBuff, \":\");\r\n\t\t*pSpliter = '\\n';\r\n\t\tsscanf(vBuff, \"%s%s\"\r\n\t\t\t, hosts[i].szHostName\r\n\t\t\t, hosts[i].szPort);\r\n\t}\r\n\r\n\treturn TRUE;\r\n}\r\n\r\nBOOL CLakeySetting::Save()\r\n{\r\n\tWriteProfileDouble(SECTION_CW, CW_BEEPFREQ, cust.m_rBeepFreq);\r\n\tWriteProfileDouble(SECTION_CW, CW_BEEPVOL, cust.m_rBeepVol);\r\n\tWriteProfileDec(SECTION_CW, CW_SHORTHIT, cust.m_nShortHit);\r\n\tWriteProfileDec(SECTION_CW, CW_LONGHIT, cust.m_nLongHit);\r\n\tWriteProfileDec(SECTION_CW, CW_HITDELAY, cust.m_nHitDelay);\r\n\tWriteProfileDec(SECTION_CW, CW_LETTERDELAY, cust.m_nLetterDelay);\r\n\tWriteProfileDec(SECTION_CW, CW_WORDDELAY, cust.m_nWordDelay);\r\n\r\n\tWriteProfileRect(SECTION_GLOBAL, GLOBAL_WINDOWRECT, &cust.m_oWindowRect);\r\n\r\n\tWriteProfileDec(SECTION_JOURNAL, JOURNAL_SENDPERIOD, cust.m_nSendJournalPeriod);\r\n\tWriteProfileDec(SECTION_JOURNAL, JOURNAL_SENDIDLELIMIT, cust.m_nSendIdleLimit);\r\n\tWriteProfileRect(SECTION_JOURNAL, JOURNAL_SENDRECT, &cust.m_oSendJournalRect);\r\n\tWriteProfileSize(SECTION_JOURNAL, JOURNAL_SENDLABELOFFSET, &cust.m_oSendLabelOffset);\r\n\tWritePrivateProfileString(SECTION_JOURNAL, JOURNAL_SENDLABEL, cust.m_vSendLabel, PROFILE_PATHNAME);\r\n\tWriteProfileRect(SECTION_JOURNAL, JOURNAL_SENDQUEUERECT, &cust.m_oSendCharQueueRect);\r\n\r\n\tWriteProfileRect(SECTION_JOURNAL, JOURNAL_SPECRECT, &cust.m_oSpectrogramRect);\r\n\tWriteProfileSize(SECTION_JOURNAL, JOURNAL_SPECLABELOFFSET, &cust.m_oSpecLabelOffset);\r\n\tWritePrivateProfileString(SECTION_JOURNAL, JOURNAL_SPECLABEL, cust.m_vSpecLabel, PROFILE_PATHNAME);\r\n\r\n\tWriteProfileDec(SECTION_JOURNAL, JOURNAL_RECVPERIOD, cust.m_nRecvJournalPeriod);\r\n\tWriteProfileDec(SECTION_JOURNAL, JOURNAL_RECVIDLELIMIT, cust.m_nRecvIdleLimit);\r\n\tWriteProfileRect(SECTION_JOURNAL, JOURNAL_RECVRECT, &cust.m_oRecvJournalRect);\r\n\tWriteProfileSize(SECTION_JOURNAL, JOURNAL_RECVLABELOFFSET, &cust.m_oRecvLabelOffset);\r\n\tWritePrivateProfileString(SECTION_JOURNAL, JOURNAL_RECVLABEL, cust.m_vRecvLabel, PROFILE_PATHNAME);\r\n\tWriteProfileRect(SECTION_JOURNAL, JOURNAL_RECVMRECT, &cust.m_oRecvMonitorRect);\r\n\tWriteProfileDec(SECTION_JOURNAL, JOURNAL_RECVANALYZESAMPLE, cust.m_nRecvAnalyzeSamples);\r\n\tWriteProfileDouble(SECTION_JOURNAL, JOURNAL_RECVTHRESHOLD, cust.m_rRecvThreshold);\r\n\tWriteProfileDec(SECTION_JOURNAL, JOURNAL_RECVFREQSTART, cust.m_nRecvFreqStart);\r\n\tWriteProfileDec(SECTION_JOURNAL, JOURNAL_RECVFREQEND, cust.m_nRecvFreqEnd);\r\n\r\n\tWriteButtonMapping(SECTION_MAINPANEL, MAINPANEL_CW, &cust.m_oCwKeyButton);\r\n\tWriteButtonMapping(SECTION_MAINPANEL, MAINPANEL_SENDPAUSE, &cust.m_oSendPauseButton);\r\n\tWriteButtonMapping(SECTION_MAINPANEL, MAINPANEL_SENDFILE, &cust.m_oSendFileButton);\r\n\tWriteButtonMapping(SECTION_MAINPANEL, MAINPANEL_AUTOKEYSWITCH, &cust.m_oAutoKeySwitchButton);\r\n\tWriteButtonMapping(SECTION_MAINPANEL, MAINPANEL_NOISESWITCH, &cust.m_oNoiseSwitchButton);\r\n\r\n\tWriteTunerMapping(SECTION_MAINPANEL, MAINPANEL_SENDVOL, &cust.m_oSendVolTuner);\r\n\tWriteTunerMapping(SECTION_MAINPANEL, MAINPANEL_NOISEVOL, &cust.m_oNoiseVolTuner);\r\n\tWriteTunerMapping(SECTION_MAINPANEL, MAINPANEL_SENDSPEED, &cust.m_oSendSpeedTuner);\r\n\tWriteTunerMapping(SECTION_MAINPANEL, MAINPANEL_SPECBRIGHTNESS, &cust.m_oSpecBrightnessTuner);\r\n\r\n\tWritePrivateProfileString(SECTION_KOCH, KOCH_CHARS, cust.m_vKochChar, PROFILE_PATHNAME);\r\n\tWriteProfileDec(SECTION_KOCH, KOCH_WORDLEN, cust.m_nKochWordLen);\r\n\r\n\tfor (int i = 0; i < MORSECODECOUNT; ++i)\r\n\t{\r\n\t\tchar vMorseKey[2] = {' ', '\\0'};\r\n\t\tchar vBuff[64];\r\n\t\tvMorseKey[0] = (char)cust.m_vMorseCode[i].nAscCode;\r\n\t\tWritePrivateProfileString(SECTION_MORSE, vMorseKey, MorseCodeToStr(vBuff, i), PROFILE_PATHNAME);\r\n\t}\r\n\r\n\t\r\n\tWriteProfileHex(SECTION_HWCTRL, HWCTRL_ENABLEEXTPORT, cust.m_nExtPortEnable);\r\n\tWriteProfileHex(SECTION_HWCTRL, HWCTRL_EXTPORTADDR, cust.m_nExtPortAddr);\r\n\tWriteProfileHex(SECTION_HWCTRL, HWCTRL_OPENBYTE, cust.m_nOpenByte);\r\n\tWriteProfileHex(SECTION_HWCTRL, HWCTRL_CLOSEBYTE, cust.m_nCloseByte);\r\n\r\n\tWriteProfileDec(SECTION_NETWORK, NETWORK_NWENABLED, cust.m_bNetworkEnabled);\r\n\tWriteProfileDec(SECTION_NETWORK, NETWORK_LOCALPORT, cust.m_nLocalPort);\r\n\tWriteProfileDec(SECTION_NETWORK, NETWORK_HOSTS, (int)hosts.size());\r\n\r\n\tchar vPropBuff[8];\r\n\tchar vHostBuff[64];\r\n\r\n\tfor (UINT i = 0; i < hosts.size(); ++i)\r\n\t{\r\n\t\tsprintf(vPropBuff, NETWORK_HOSTENTRYEXPR, i + 1);\r\n\t\tsprintf(vHostBuff, \"%s:%s\", hosts[i].szHostName, hosts[i].szPort);\r\n\t\tWritePrivateProfileString(SECTION_NETWORK, vPropBuff, vHostBuff, PROFILE_PATHNAME);\r\n\t}\r\n\r\n\treturn TRUE;\r\n}\r\n\r\nint CLakeySetting::GetProfileHex(const char* pSec, const char* pKey, int nDefault)\r\n{\r\n\tchar vBuff[32];\r\n\tGetPrivateProfileString(pSec, pKey, \"\", vBuff, sizeof(vBuff), PROFILE_PATHNAME);\r\n\tif (strlen(vBuff))\r\n\t\tsscanf(vBuff, \"%8X\", &nDefault);\r\n\r\n\treturn nDefault;\r\n}\r\n\r\nvoid CLakeySetting::WriteProfileHex(const char* pSec, const char* pKey, int n)\r\n{\r\n\tchar vBuff[32];\r\n\tsprintf(vBuff, \"%8.8X\", n);\r\n\r\n\tWritePrivateProfileString(pSec, pKey, vBuff, PROFILE_PATHNAME);\r\n}\r\n\r\nint CLakeySetting::GetProfileDec(const char* pSec, const char* pKey, int nDefault)\r\n{\r\n\tchar vBuff[32];\r\n\tGetPrivateProfileString(pSec, pKey, \"\", vBuff, sizeof(vBuff), PROFILE_PATHNAME);\r\n\tif (strlen(vBuff))\r\n\t\tsscanf(vBuff, \"%d\", &nDefault);\r\n\r\n\treturn nDefault;\r\n}\r\n\r\nvoid CLakeySetting::WriteProfileDec(const char* pSec, const char* pKey, int n)\r\n{\r\n\tchar vBuff[32];\r\n\tsprintf(vBuff, \"%d\", n);\r\n\r\n\tWritePrivateProfileString(pSec, pKey, vBuff, PROFILE_PATHNAME);\r\n}\r\n\r\ndouble CLakeySetting::GetProfileDouble(const char* pSec, const char* pKey, double rDefault)\r\n{\r\n\tchar vBuff[32];\r\n\tGetPrivateProfileString(pSec, pKey, \"\", vBuff, sizeof(vBuff), PROFILE_PATHNAME);\r\n\tif (strlen(vBuff))\r\n\t\tsscanf(vBuff, \"%lf\", &rDefault);\r\n\r\n\treturn rDefault;\r\n}\r\n\r\nvoid CLakeySetting::WriteProfileDouble(const char* pSec, const char* pKey, double r)\r\n{\r\n\tchar vBuff[32];\r\n\tsprintf(vBuff, \"%lf\", r);\r\n\r\n\tWritePrivateProfileString(pSec, pKey, vBuff, PROFILE_PATHNAME);\r\n}\r\n\r\nvoid CLakeySetting::GetButtonMapping(const char* pSec, const char* pKey, BUTTONMAPPING* pBtMap)\r\n{\r\n\tchar vBuff[64];\r\n\tGetPrivateProfileString(pSec, pKey, \"\", vBuff, sizeof(vBuff), PROFILE_PATHNAME);\r\n\tif (strlen(vBuff))\r\n\t\tStrToButtonMapping(pBtMap, vBuff);\r\n}\r\n\r\nvoid CLakeySetting::WriteButtonMapping(const char* pSec, const char* pKey, const BUTTONMAPPING* pBtMap)\r\n{\r\n\tchar vBuff[64];\r\n\tWritePrivateProfileString(pSec, pKey, ButtonMappingToStr(vBuff, pBtMap), PROFILE_PATHNAME);\r\n}\r\n\r\nvoid CLakeySetting::GetTunerMapping(const char* pSec, const char* pKey, TUNERMAPPING* pTnMap)\r\n{\r\n\tchar vBuff[64];\r\n\tGetPrivateProfileString(pSec, pKey, \"\", vBuff, sizeof(vBuff), PROFILE_PATHNAME);\r\n\tif (strlen(vBuff))\r\n\t\tStrToTunerMapping(pTnMap, vBuff);\r\n}\r\n\r\nvoid CLakeySetting::WriteTunerMapping(const char* pSec, const char* pKey, const TUNERMAPPING* pTnMap)\r\n{\r\n\tchar vBuff[64];\r\n\tWritePrivateProfileString(pSec, pKey, TunerMappingToStr(vBuff, pTnMap), PROFILE_PATHNAME);\r\n}\r\n\r\nvoid CLakeySetting::GetProfileRect(const char* pSec, const char* pKey, RECT* pRect)\r\n{\r\n\tchar vBuff[64];\r\n\tGetPrivateProfileString(pSec, pKey, \"\", vBuff, sizeof(vBuff), PROFILE_PATHNAME);\r\n\tif (strlen(vBuff))\r\n\t\tsscanf(vBuff, \"%d,%d,%d,%d\", &pRect->left, &pRect->top, &pRect->right, &pRect->bottom);\r\n}\r\n\r\nvoid CLakeySetting::WriteProfileRect(const char* pSec, const char* pKey, const RECT* pRect)\r\n{\r\n\tchar vBuff[64];\r\n\tsprintf(vBuff, \"%d,%d,%d,%d\", pRect->left, pRect->top, pRect->right, pRect->bottom);\r\n\tWritePrivateProfileString(pSec, pKey, vBuff, PROFILE_PATHNAME);\r\n}\r\n\r\nvoid CLakeySetting::GetProfileSize(const char* pSec, const char* pKey, SIZE* pSize)\r\n{\r\n\tchar vBuff[64];\r\n\tGetPrivateProfileString(pSec, pKey, \"\", vBuff, sizeof(vBuff), PROFILE_PATHNAME);\r\n\tif (strlen(vBuff))\r\n\t\tsscanf(vBuff, \"%d,%d\", &pSize->cx, &pSize->cy);\r\n}\r\n\r\nvoid CLakeySetting::WriteProfileSize(const char* pSec, const char* pKey, const SIZE* pSize)\r\n{\r\n\tchar vBuff[64];\r\n\tsprintf(vBuff, \"%d,%d\", pSize->cx, pSize->cy);\r\n\tWritePrivateProfileString(pSec, pKey, vBuff, PROFILE_PATHNAME);\r\n}\r\n\r\nvoid CLakeySetting::GetCustomize(CUSTOMIZE* pCust)\r\n{\r\n\tmemcpy(pCust, &cust, sizeof(cust));\r\n\tmemcpy(pCust->m_vKochChar, cust.m_vKochChar, sizeof(cust.m_vKochChar));\r\n}\r\n\r\nvoid CLakeySetting::SetCustomize(const CUSTOMIZE* pCust)\r\n{\r\n\tmemcpy(&cust, pCust, sizeof(cust));\r\n\tmemcpy(cust.m_vKochChar, pCust->m_vKochChar, sizeof(cust.m_vKochChar));\r\n}\r\n\r\nfloat calcStdWordLen(short int nMorseCode, short int nMask)\r\n{\r\n\tint s = 2; // word space - hit space\r\n\tdo\r\n\t{\r\n\t\tif (0x01 & nMorseCode)\r\n\t\t{\r\n\t\t\t// di\r\n\t\t\ts += 2;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\t// dah\r\n\t\t\ts += 4;\r\n\t\t}\r\n\t}\r\n\twhile(0x01 & (nMask >>= 1));\r\n\r\n\treturn (float)s / (float)STD_WORD_LEN;\r\n}\r\n\r\nvoid wpmToParams(WPMS* pWpms)\r\n{\r\n\t// .--. .- .-. .. ...\r\n\tpWpms->di = (int)(60 * 1000 / (pWpms->wpm * STD_WORD_LEN));\r\n\tpWpms->dah = pWpms->di * 3;\r\n\tpWpms->hdelay = pWpms->di;\r\n\tpWpms->ldelay = pWpms->di * 3;\r\n\tpWpms->wdelay = pWpms->di * 3;\r\n}\r\n\r\nvoid paramsToWpm(WPMS* pWpms)\r\n{\r\n\tshort nCalc = 10 * pWpms->di\r\n\t\t+ 4 * pWpms->dah\r\n\t\t+ 9 * pWpms->hdelay\r\n\t\t+ 4 * pWpms->ldelay\r\n\t\t+ 1 * pWpms->wdelay;\r\n\r\n\tif (0 == nCalc)\r\n\t\tnCalc = 1;\r\n\r\n\tnCalc = (60 * 1000 + nCalc / 2) / nCalc;\r\n\r\n\tif (99 < nCalc)\r\n\t\tnCalc = 99;\r\n\r\n\tpWpms->wpm = nCalc;\r\n}\r\n"
  },
  {
    "path": "src/LakeySetting.h",
    "content": "#pragma once\r\n\r\n#include <windows.h>\r\n#include <vector>\r\n#include \"LaTuner.h\"\r\n\r\nusing namespace std;\r\n\r\n#define MORSECODECOUNT\t\t42\r\n#define PROFILE\t\t\t\t\"lakey.ini\"\r\n#define HOSTS_MAX\t\t\t8\r\n#define HOSTS_NAME_LEN\t\t64\r\n// PARIS: .--. .- .-. .. ...\r\n#define STD_WORD_LEN\t\t46\r\n\r\n\r\ntypedef struct tagMorseCode\r\n{\r\n\tunsigned int\tnAscCode;\r\n\tunsigned short int\tnMorseCode;\r\n\tunsigned short int\tnMask;\r\n\tunsigned int\tnKeyCode;\r\n\tfloat\t\t\trStdWordLen;\r\n} MORSECODE;\r\n\r\ntypedef struct tagButtonMapping\r\n{\r\n\tint\t\tx;\r\n\tint\t\ty;\r\n\tint\t\tw;\r\n\tint\t\th;\r\n\tint\t\tnKeyCode;\r\n\tchar\tvLabel[128];\r\n} BUTTONMAPPING;\r\n\r\ntypedef struct tagTunerMapping\r\n{\r\n\tint\t\tx;\r\n\tint\t\ty;\r\n\tint\t\tw;\r\n\tint\t\th;\r\n\tLASCALE\tvl;\r\n\tLASCALE\tvr;\r\n\tLASCALE\tv;\r\n\tchar\tvLabel[128];\r\n} TUNERMAPPING;\r\n\r\ntypedef struct tagHostNode\r\n{\r\n\tchar\tszHostName[60];\r\n\tchar\tszPort[8];\r\n} HOSTNODE;\r\n\r\ntypedef vector<HOSTNODE> HostList;\r\n\r\ntypedef struct tagCustomize\r\n{\r\n\tdouble\t\tm_rBeepFreq;\r\n\tdouble\t\tm_rBeepVol;\r\n\tint\t\t\tm_nShortHit;\r\n\tint\t\t\tm_nLongHit;\r\n\tint\t\t\tm_nHitDelay;\r\n\tint\t\t\tm_nLetterDelay;\r\n\tint\t\t\tm_nWordDelay;\r\n\r\n\tRECT\t\tm_oWindowRect;\r\n\r\n\tint\t\t\tm_nSendJournalPeriod;\r\n\tint\t\t\tm_nSendIdleLimit;\r\n\tRECT\t\tm_oSendJournalRect;\r\n\tSIZE\t\tm_oSendLabelOffset;\r\n\tchar\t\tm_vSendLabel[16];\r\n\tRECT\t\tm_oSendCharQueueRect;\r\n\tint\t\t\tm_nRecvJournalPeriod;\r\n\tint\t\t\tm_nRecvIdleLimit;\r\n\tRECT\t\tm_oRecvJournalRect;\r\n\tSIZE\t\tm_oRecvLabelOffset;\r\n\tchar\t\tm_vRecvLabel[16];\r\n\tRECT\t\tm_oRecvMonitorRect;\r\n\tint\t\t\tm_nRecvAnalyzeSamples;\r\n\tdouble\t\tm_rRecvThreshold;\r\n\tint\t\t\tm_nRecvFreqStart;\r\n\tint\t\t\tm_nRecvFreqEnd;\r\n\r\n\tRECT\t\tm_oSpectrogramRect;\r\n\tSIZE\t\tm_oSpecLabelOffset;\r\n\tchar\t\tm_vSpecLabel[16];\r\n\r\n\tBUTTONMAPPING\tm_oCwKeyButton;\r\n\tBUTTONMAPPING\tm_oSendPauseButton;\r\n\tBUTTONMAPPING\tm_oSendFileButton;\r\n\tBUTTONMAPPING\tm_oAutoKeySwitchButton;\r\n\tBUTTONMAPPING\tm_oNoiseSwitchButton;\r\n\r\n\tTUNERMAPPING\tm_oSendVolTuner;\r\n\tTUNERMAPPING\tm_oNoiseVolTuner;\r\n\tTUNERMAPPING\tm_oSendSpeedTuner;\r\n\tTUNERMAPPING\tm_oSpecBrightnessTuner;\r\n\r\n\tchar\t\tm_vKochChar[MORSECODECOUNT + 1];\r\n\tint\t\t\tm_nKochWordLen;\r\n\r\n\tMORSECODE\tm_vMorseCode[MORSECODECOUNT];\r\n\r\n\tint\t\t\tm_nExtPortEnable;\r\n\tWORD\t\tm_nExtPortAddr;\r\n\tBYTE\t\tm_nOpenByte;\r\n\tBYTE\t\tm_nCloseByte;\r\n\r\n\tWORD\t\tm_nLocalPort;\r\n\tBOOL\t\tm_bNetworkEnabled;\r\n\t//char\t\tm_vHostList[HOSTS_MAX][HOSTS_NAME_LEN];\r\n\r\n\t//Styles\r\n\t//Frequency Analyzer\r\n\tint\t\t\tm_nFaBgColor;\r\n\tint\t\t\tm_nFaWaveColor;\r\n\tint\t\t\tm_nFaFloatColor;\r\n\tint\t\t\tm_nFaFreqAnaColor;\r\n\r\n} CUSTOMIZE;\r\n\r\ntypedef struct tagWPMS\r\n{\r\n\tfloat\t\twpm;\r\n\tint\t\tdi;\r\n\tint\t\tdah;\r\n\tint\t\thdelay;\r\n\tint\t\tldelay;\r\n\tint\t\twdelay;\r\n} WPMS;\r\n\r\nvoid wpmToParams(WPMS* pWpms);\r\nvoid paramsToWpm(WPMS* pWpms);\r\nfloat calcStdWordLen(short int nMorseCode, short int nMask);\r\n\r\nclass CLakeySetting\r\n{\r\npublic:\r\n\tCLakeySetting(void);\r\n\tvirtual ~CLakeySetting(void);\r\n\r\n\tvirtual BOOL Load();\r\n\tvirtual BOOL Save();\r\n\r\n\tCUSTOMIZE\tcust;\r\n\tHostList\thosts;\r\n\r\n\tvirtual void GetCustomize(CUSTOMIZE* pCust);\r\n\tvirtual void SetCustomize(const CUSTOMIZE* pCust);\r\n\r\nprivate:\r\n\tvoid StrToMorseCode(int nIdx, const char* pStr);\r\n\tchar* MorseCodeToStr(char* pStr, int nIdx);\r\n\tchar* ButtonMappingToStr(char* pStr, const BUTTONMAPPING* pMapping);\r\n\tvoid StrToButtonMapping(BUTTONMAPPING* pMapping, const char* pStr);\r\n\r\n\tchar* TunerMappingToStr(char* pStr, const TUNERMAPPING* pMapping);\r\n\tvoid StrToTunerMapping(TUNERMAPPING* pMapping, const char* pStr);\r\n\r\n\tint GetProfileHex(const char* pSec, const char* pKey, int nDefault);\r\n\tvoid WriteProfileHex(const char* pSec, const char* pKey, int n);\r\n\tint GetProfileDec(const char* pSec, const char* pKey, int nDefault);\r\n\tvoid WriteProfileDec(const char* pSec, const char* pKey, int n);\r\n\tdouble GetProfileDouble(const char* pSec, const char* pKey, double rDefault);\r\n\tvoid WriteProfileDouble(const char* pSec, const char* pKey, double r);\r\n\r\n\tvoid GetButtonMapping(const char* pSec, const char* pKey, BUTTONMAPPING* pBtMap);\r\n\tvoid WriteButtonMapping(const char* pSec, const char* pKey, const BUTTONMAPPING* pBtMap);\r\n\r\n\tvoid GetTunerMapping(const char* pSec, const char* pKey, TUNERMAPPING* pTnMap);\r\n\tvoid WriteTunerMapping(const char* pSec, const char* pKey, const TUNERMAPPING* pTnMap);\r\n\r\n\tvoid GetProfileRect(const char* pSec, const char* pKey, RECT* pRect);\r\n\tvoid WriteProfileRect(const char* pSec, const char* pKey, const RECT* pRect);\r\n\r\n\tvoid GetProfileSize(const char* pSec, const char* pKey, SIZE* pSize);\r\n\tvoid WriteProfileSize(const char* pSec, const char* pKey, const SIZE* pSize);\r\n\r\n};\r\n"
  },
  {
    "path": "src/MorseParser.cpp",
    "content": "#include \"StdAfx.h\"\r\n#include \"morseparser.h\"\r\n\r\nCMorseParser::CMorseParser(const MORSECODE* pMorseList, int nCount, int nMaxShortCount, IParseEventListener* pListener)\r\n{\r\n\tm_pMorseCodeTree = new MORSECODETREENODE;\r\n\tm_pMorseCodeTree->pMorseCode = NULL;\r\n\tm_pMorseCodeTree->pDi = m_pMorseCodeTree->pDa = NULL;\r\n\r\n\tfor (int i = 0; i < nCount; ++i)\r\n\t{\r\n\t\tAddNode(m_pMorseCodeTree, pMorseList + i, ((pMorseList + i)->nMask + 1) >> 1);\r\n\t}\r\n\r\n\tm_pCurrNode = m_pMorseCodeTree;\r\n\tm_nLastState = 0;\r\n\tm_nStateCount = 0;\r\n\r\n\tm_nMaxShortCount = nMaxShortCount;\r\n\tm_pParseEventListener = pListener;\r\n\tm_nStep = 1;\r\n}\r\n\r\nCMorseParser::~CMorseParser(void)\r\n{\r\n\tReleaseAllNodes(m_pMorseCodeTree);\r\n}\r\n\r\nvoid CMorseParser::AddNode(MORSECODETREENODE* pCurrNode, const MORSECODE* pMorseCode, int nMcWin)\r\n{\r\n\tif (!nMcWin)\r\n\t{\r\n\t\t// position it!\r\n\t\tpCurrNode->pMorseCode = pMorseCode;\r\n\t}\r\n\telse\r\n\t{\r\n\t\tif (pMorseCode->nMorseCode & nMcWin)\r\n\t\t{\r\n\t\t\tif (!pCurrNode->pDi)\r\n\t\t\t{\r\n\t\t\t\tpCurrNode->pDi = new MORSECODETREENODE;\r\n\t\t\t\tpCurrNode->pDi->pMorseCode = NULL;\r\n\t\t\t\tpCurrNode->pDi->pDi = pCurrNode->pDi->pDa = NULL;\r\n\t\t\t}\r\n\r\n\t\t\tAddNode(pCurrNode->pDi, pMorseCode, nMcWin >> 1);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tif (!pCurrNode->pDa)\r\n\t\t\t{\r\n\t\t\t\tpCurrNode->pDa = new MORSECODETREENODE;\r\n\t\t\t\tpCurrNode->pDa->pMorseCode = NULL;\r\n\t\t\t\tpCurrNode->pDa->pDi = pCurrNode->pDa->pDa = NULL;\r\n\t\t\t}\r\n\r\n\t\t\tAddNode(pCurrNode->pDa, pMorseCode, nMcWin >> 1);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid CMorseParser::ReleaseAllNodes(MORSECODETREENODE* pRoot)\r\n{\r\n\tif (!pRoot)\r\n\t{\r\n\t\tReleaseAllNodes(pRoot->pDi);\r\n\t\tReleaseAllNodes(pRoot->pDa);\r\n\t\tdelete pRoot;\r\n\t}\r\n}\r\n\r\nvoid CMorseParser::Sample(int nState)\r\n{\r\n\tswitch(m_nStep)\r\n\t{\r\n\t\tcase 1: // test start new letter\r\n\t\t\tif (1 == nState)\r\n\t\t\t{\r\n\t\t\t\tm_nStateCount = 1;\r\n\t\t\t\tm_pCurrNode = m_pMorseCodeTree;\r\n\t\t\t\tm_nStep = 2;\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase 2:\r\n\t\t\tif (0 == nState)\r\n\t\t\t{\r\n\t\t\t\tm_nStep = 3;\r\n\t\t\t\tif (m_nStateCount > m_nMaxShortCount)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (m_pCurrNode->pDa)\r\n\t\t\t\t\t\tm_pCurrNode = m_pCurrNode->pDa;\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tm_pParseEventListener->OnWorkOut(this, m_pCurrNode->pMorseCode);\r\n\t\t\t\t\t\tm_nStep = 1;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tif (m_pCurrNode->pDi)\r\n\t\t\t\t\t\tm_pCurrNode = m_pCurrNode->pDi;\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tm_pParseEventListener->OnWorkOut(this, m_pCurrNode->pMorseCode);\r\n\t\t\t\t\t\tm_nStep = 1;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tm_nStateCount = 0;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t\t++m_nStateCount;\r\n\t\t\tbreak;\r\n\t\tcase 3:\r\n\t\t\tif (1 == nState)\r\n\t\t\t{\r\n\t\t\t\tif (m_nStateCount > m_nMaxShortCount)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (m_pCurrNode->pMorseCode)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tm_pParseEventListener->OnWorkOut(this, m_pCurrNode->pMorseCode);\r\n\t\t\t\t\t\tm_pCurrNode = m_pMorseCodeTree;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tm_nStateCount = 1;\r\n\t\t\t\tm_nStep = 2;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tif (++m_nStateCount > m_nMaxShortCount)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (m_pCurrNode->pMorseCode)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tm_pParseEventListener->OnWorkOut(this, m_pCurrNode->pMorseCode);\r\n\t\t\t\t\t\tm_nStep = 1;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse if (!m_pCurrNode->pDi && !m_pCurrNode->pDa || m_nStateCount > 1.5 * m_nMaxShortCount)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tm_pParseEventListener->OnWorkOut(this, NULL);\r\n\t\t\t\t\t\tm_nStep = 1;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t}\r\n}\r\n"
  },
  {
    "path": "src/MorseParser.h",
    "content": "#pragma once\r\n\r\n#include \"LakeySetting.h\"\r\n\r\nclass IParseEventListener\r\n{\r\npublic:\r\n\tvirtual void OnWorkOut(void* owner, const MORSECODE* pResult) = 0;\r\n};\r\n\r\ntypedef struct tagMorseCodeTreeNode\r\n{\r\n\tconst MORSECODE*\t\t\t\tpMorseCode;\r\n\tstruct tagMorseCodeTreeNode*\tpDi;\r\n\tstruct tagMorseCodeTreeNode*\tpDa;\r\n} MORSECODETREENODE;\r\n\r\nclass CMorseParser\r\n{\r\npublic:\r\n\tCMorseParser(const MORSECODE* pMorseList, int nCount, int nMaxShortCount, IParseEventListener* pListener);\r\n\tvirtual ~CMorseParser();\r\n\r\n\tvoid SetMaxShortCount(int nCount) { m_nMaxShortCount = nCount; };\r\n\tvoid Sample(int nState);\r\n\r\nprivate:\r\n\tvoid AddNode(MORSECODETREENODE* pCurrNode, const MORSECODE* pMorseCode, int nMcWin);\r\n\tvoid ReleaseAllNodes(MORSECODETREENODE* pRoot);\r\n\r\n\tMORSECODETREENODE*\t\tm_pMorseCodeTree;\r\n\tint\t\t\t\t\t\tm_nMaxShortCount;\r\n\tIParseEventListener*\tm_pParseEventListener;\r\n\r\n\t// for parse work\r\n\tMORSECODETREENODE*\t\tm_pCurrNode;\r\n\tint\t\t\t\t\t\tm_nLastState;\r\n\tint\t\t\t\t\t\tm_nStateCount;\r\n\tint\t\t\t\t\t\tm_nStep;\r\n};\r\n\r\n"
  },
  {
    "path": "src/ReadMe.txt",
    "content": "========================================================================\r\n    WIN32 Ӧó : Lakey Ŀſ\r\n========================================================================\r\n\r\nӦóΪ Lakey Ӧó\r\nļ Lakey Ӧó\r\nÿļժҪ\r\n\r\n\r\nLakey.vcproj\r\n    Ӧóɵ VC++ ĿĿļ\r\n    йɴļ Visual C++ 汾ϢԼ\r\n    йӦóѡ\r\n    ƽ̨úĿܵϢ\r\n\r\nLakey.cpp\r\n    ӦóԴļ\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\nӦóѴԴ\r\n\r\nLakey.rc\r\n    ǳʹõ Microsoft Windows Դб\r\n    洢 RES Ŀ¼µͼꡢλͼ͹ꡣ\r\n    ļ Microsoft Visual C++ ֱӱ༭\r\n    \r\n\r\nResource.h\r\n    Ǳ׼ͷļµԴ ID\r\n    Microsoft Visual C++ ȡ͸´ļ\r\nLakey.ico\r\n    һͼļӦóͼ (32x32)\r\n    ͼλԴļ Lakey.rc С\r\n\r\nsmall.ico\r\n    һͼļС汾 (16x16) \r\n    ӦóͼꡣͼλԴ\r\n    ļ Lakey.rc С\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n׼ļ\r\n\r\nStdAfx.hStdAfx.cpp\r\n    ЩļΪ Lakey.pch\r\n    Ԥͷ (PCH) ļԼΪ StdAfx.obj Ԥļ\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\nעͣ\r\n\r\nӦóʹ \"TODO:\" עָʾԴӦӵĻԶ\r\nĲ֡\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n"
  },
  {
    "path": "src/Resource.h",
    "content": "//{{NO_DEPENDENCIES}}\r\n// Microsoft Visual C++ generated include file.\r\n// Used by Lakey.rc\r\n//\r\n#define IDC_MYICON                      2\r\n#define IDD_LAKEY_DIALOG                102\r\n#define IDS_APP_TITLE                   103\r\n#define IDD_ABOUTBOX                    103\r\n#define IDM_ABOUT                       104\r\n#define IDD_SETTINGS                    104\r\n#define IDM_EXIT                        105\r\n#define IDI_LAKEY                       107\r\n#define IDI_SMALL                       108\r\n#define IDC_LAKEY                       109\r\n#define IDR_MAINFRAME                   128\r\n#define ID_129                          129\r\n#define IDB_BITMAP1                     131\r\n#define IDB_LOGO                        131\r\n#define ID_KOCH                         132\r\n#define ID__                            133\r\n#define ID_KOCH_134                     134\r\n#define IDD_COPYPAD                     135\r\n#define IDD_TEST                        136\r\n#define IDD_GENERAL                     137\r\n#define IDM_TEST                        199\r\n#define IDC_EDIT1                       1000\r\n#define IDC_TONE                        1001\r\n#define IDC_BEEPFREQ                    1002\r\n#define IDC_COPYTEXT                    1003\r\n#define IDC_SETTINGSTAB                 1004\r\n#define IDC_BEEPVOL                     1005\r\n#define IDM_SETTINGS                    1006\r\n#define IDC_SENDPERIOD                  1007\r\n#define IDC_BUTTON1                     1008\r\n#define IDC_HOSTADD                     1008\r\n#define IDC_SENDILDELIMIT               1009\r\n#define IDC_RECVPERIOD                  1010\r\n#define IDC_RECVILDELIMIT               1011\r\n#define IDC_RECVANALYZESAMPLES          1012\r\n#define IDC_RECVTHRESHOLD               1013\r\n#define IDC_RECVFREQSTART               1014\r\n#define IDC_RECVFREQEND                 1015\r\n#define IDC_HOTKEY1                     1016\r\n#define IDC_CALCSPEED                   1017\r\n#define IDC_SHORTHIT                    1018\r\n#define IDC_LONGHIT                     1019\r\n#define IDC_HITDELAY                    1020\r\n#define IDC_LETTERDELAY                 1021\r\n#define IDC_CW                          1022\r\n#define ID_ACCEPT                       1023\r\n#define IDC_ACCEPT                      1024\r\n#define IDC_SPEED                       1025\r\n#define IDC_KOCHCHARS                   1026\r\n#define IDC_ELAPSETIME                  1027\r\n#define IDC_COPIED                      1028\r\n#define IDC_INCORRECT                   1029\r\n#define IDC_CORRECTPERC                 1030\r\n#define IDC_RICHEDIT21                  1031\r\n#define IDC_LOCALPORT                   1032\r\n#define IDC_NWNODES                     1033\r\n#define IDC_HOSTPORT                    1033\r\n#define IDC_TAB1                        1034\r\n#define IDC_HOSTLIST                    1034\r\n#define IDC_HOSTADDR                    1035\r\n#define IDC_HOSTNAME                    1035\r\n#define IDC_HOSTDEL                     1036\r\n#define IDC_CHECK1                      1038\r\n#define IDC_NWENABLED                   1038\r\n#define IDM_KOCHSTART                   1051\r\n#define IDM_KOCHSTOP                    1052\r\n#define IDM_KOCHWAVE                    1053\r\n#define IDM_PROMPTWAVE                  1054\r\n#define IDM_SENDTRAINING\t\t\t\t1055\r\n#define IDC_KOCHWORDLEN                 1061\r\n#define IDC_WORDDELAY                   1062\r\n#define IDD_PROMPTBOX                   1065\r\n#define IDC_INPUTSTR                    1066\r\n#define IDD_SEND                        1067\r\n#define IDC_PROMPTTEXT                  1068\r\n#define IDD_RECV                        1072\r\n#define IDD_IO                          1073\r\n#define IDD_KOCH                        1074\r\n#define IDD_NETWORK                     1075\r\n#define IDD_SETTINGS2                   1076\r\n#define IDC_EXTPORTENABLE               1100\r\n#define IDC_EXTPORTADDR                 1101\r\n#define IDC_OPENBYTE                    1102\r\n#define IDC_CLOSEBYTE                   1103\r\n#define IDA_TEST                        32775\r\n#define IDC_STATIC                      -1\r\n\r\n// Next default values for new objects\r\n// \r\n#ifdef APSTUDIO_INVOKED\r\n#ifndef APSTUDIO_READONLY_SYMBOLS\r\n#define _APS_NO_MFC                     1\r\n#define _APS_NEXT_RESOURCE_VALUE        138\r\n#define _APS_NEXT_COMMAND_VALUE         32777\r\n#define _APS_NEXT_CONTROL_VALUE         1039\r\n#define _APS_NEXT_SYMED_VALUE           110\r\n#endif\r\n#endif\r\n"
  },
  {
    "path": "src/SinSound.cpp",
    "content": "#include \"StdAfx.h\"\r\n#include \"dsound.h\"\r\n#include \"math.h\"\r\n#include \"sinsound.h\"\r\n\r\nstatic float DW = 0;\r\n\r\nCSinSound::CSinSound()\r\n\t:m_pDs(NULL),\r\n\tm_pDsb(NULL),\r\n\tm_pBgDsb(NULL),\r\n\tm_bFormatValid(FALSE),\r\n\tm_bDsbValid(FALSE),\r\n\tm_bDataValid(FALSE),\r\n\tm_nLastEnd(0),\r\n\tm_nTimeAxis(0),\r\n\tm_bNoiseOn(FALSE)\r\n{\r\n\tmemset(&m_oPlayedBufferDesc, 0, sizeof(m_oPlayedBufferDesc)); \r\n\tmemset(&m_oBgBufferDesc, 0, sizeof(m_oBgBufferDesc));\r\n\tmemset(&m_oFormat, 0, sizeof(m_oFormat)); \r\n\r\n\tm_oFormat.wFormatTag = WAVE_FORMAT_PCM;\r\n\tm_oFormat.nChannels = 1;\r\n\tm_oFormat.nSamplesPerSec = 44100;\r\n\tm_oFormat.wBitsPerSample = 16;\r\n\tm_oFormat.nAvgBytesPerSec = m_oFormat.nSamplesPerSec * (m_oFormat.wBitsPerSample / 8) * m_oFormat.nChannels;\r\n\tm_oFormat.nBlockAlign = 2;\r\n\tm_oFormat.cbSize = 0;\r\n\tDW = 2 * PI / m_oFormat.nSamplesPerSec;\r\n\r\n\tSetFrequency(1000);\r\n\tSetScale(1.0l);\r\n}\r\n\r\nCSinSound::~CSinSound(void)\r\n{\r\n\tif (NULL != m_pDsb)\r\n\t{\r\n\t\tm_pDsb->Release();\r\n\t\tm_pDsb = NULL;\r\n\t}\r\n\tif (NULL != m_pBgDsb)\r\n\t{\r\n\t\tm_pBgDsb->Release();\r\n\t\tm_pBgDsb = NULL;\r\n\t}\r\n\tif (NULL != m_pDs)\r\n\t{\r\n\t\tm_pDs->Release();\r\n\t\tm_pDs = NULL;\r\n\t}\r\n}\r\n\r\nBOOL CSinSound::Initialize(HWND hWnd)\r\n{\r\n\tHRESULT hr =\r\n\t\tDirectSoundCreate(NULL, &m_pDs, NULL);\r\n\tif (FAILED(hr))\r\n\t\treturn FALSE;\r\n\r\n\thr = m_pDs->SetCooperativeLevel(hWnd, DSSCL_PRIORITY);\r\n\tif (FAILED(hr))\r\n\t\treturn FALSE;\r\n\r\n\treturn InitBufferFormat();\r\n}\r\n\r\nBOOL CSinSound::OnTimer(void* owner, int nTimerId)\r\n{\r\n\tFillBackground();\r\n\treturn TRUE;\r\n}\r\n\r\nvoid CSinSound::FillBackground()\r\n{\r\n\tif (m_bFormatValid)\r\n\t{\r\n\t\tDWORD dwOffset;\r\n\r\n\t\tif (SUCCEEDED(m_pBgDsb->GetCurrentPosition(&dwOffset, NULL)))\r\n\t\t{\r\n\t\t\tDWORD nSafeLength = m_oFormat.nAvgBytesPerSec * 1;\r\n\t\t\tDWORD nSoundBytes = \r\n\t\t\t\tdwOffset <= m_nLastEnd \r\n\t\t\t\t? nSafeLength - (m_nLastEnd - dwOffset + 2)\r\n\t\t\t\t: nSafeLength - (m_oBgBufferDesc.dwBufferBytes - dwOffset + m_nLastEnd - 2);\r\n\t\t\tif (nSoundBytes > nSafeLength)\r\n\t\t\t\tnSoundBytes = nSafeLength;\r\n\r\n\t\t\tLPVOID  lpvPtr1, lpvPtr2; \r\n\t\t\tDWORD dwBytes1, dwBytes2; \r\n\r\n\t\t\tHRESULT hr = m_pBgDsb->Lock(m_nLastEnd, nSoundBytes, &lpvPtr1, &dwBytes1, &lpvPtr2, &dwBytes2, 0); \r\n\r\n\t\t\t// If the buffer was lost, restore and retry lock. \r\n\r\n\t\t\tif (DSERR_BUFFERLOST == hr) \r\n\t\t\t{ \r\n\t\t\t\tm_pBgDsb->Restore(); \r\n\t\t\t\thr = m_pBgDsb->Lock(m_nLastEnd, nSoundBytes, &lpvPtr1, &dwBytes1, &lpvPtr2, &dwBytes2, 0);  \r\n\t\t\t}\r\n\r\n\t\t\tif (FAILED(hr))\r\n\t\t\t\treturn;\r\n\t\t\t\r\n\t\t\tif (m_bNoiseOn)\r\n\t\t\t{\r\n\t\t\t\tFillNoises(lpvPtr1, dwBytes1);\r\n\r\n\t\t\t\tif (lpvPtr2)\r\n\t\t\t\t\tFillNoises(lpvPtr2, dwBytes2);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tFillBlank(lpvPtr1, dwBytes1);\r\n\r\n\t\t\t\tif (lpvPtr2)\r\n\t\t\t\t\tFillBlank(lpvPtr2, dwBytes2);\r\n\t\t\t}\r\n\r\n\t\t\tm_pBgDsb->Unlock(lpvPtr1, dwBytes1, lpvPtr2, dwBytes2);\r\n\r\n\t\t\tm_nLastEnd += nSoundBytes;\r\n\t\t\tif (m_nLastEnd >= m_oBgBufferDesc.dwBufferBytes)\r\n\t\t\t\tm_nLastEnd -= m_oBgBufferDesc.dwBufferBytes;\r\n\t\t}\r\n\t}\r\n}\r\n\r\ninline void CSinSound::FillBlank(LPVOID lpvPtr, DWORD nBytes)\r\n{\r\n\tDWORD dw = nBytes / 2;\r\n\tfor (DWORD i = 0; i < dw; ++i)\r\n\t{\r\n\t\t*(((short int *)lpvPtr) + i) = 0;\r\n\t}\r\n}\r\n\r\n#define NOISE_FREQ_STEP\t\t0.001f\r\ninline void CSinSound::FillNoises(LPVOID lpvPtr, DWORD nBytes)\r\n{\r\n\tDWORD dw = nBytes / 2;\r\n\tstatic REAL f = 0;\r\n\tstatic REAL df = NOISE_FREQ_STEP;\r\n\tstatic REAL w = 0;\r\n\tstatic int NC = 0;\r\n\tstatic BOOL bNC = TRUE;\r\n\tREAL wnl = m_rNoiseScale / 2;\r\n\tREAL nl = m_rNoiseScale * 32767;\r\n\tREAL v = 0;\r\n\tREAL t;\r\n\tint rnd;\r\n\tstatic REAL ft = m_rFrequencyHz / 2;\r\n\r\n\tfor (DWORD i = 0; i < dw; ++i)\r\n\t{\r\n\t\t++m_nTimeAxis;\r\n\t\trnd = rand();\r\n\t\tif ((f += df) >= ft && df > 0)\r\n\t\t{\r\n\t\t\tf = ft;\r\n\t\t\tft = (REAL)(abs(rnd) % (int)m_rFrequencyHz * 2);\r\n\t\t\tif (ft < f)\r\n\t\t\t\tdf = -NOISE_FREQ_STEP;\r\n\t\t}\r\n\t\telse if (f <= ft && df < 0)\r\n\t\t{\r\n\t\t\tf = ft;\r\n\t\t\tft = (REAL)(abs(rnd) % (int)m_rFrequencyHz * 2);\r\n\t\t\tif (ft > f)\r\n\t\t\t\tdf = NOISE_FREQ_STEP;\r\n\t\t}\r\n\r\n\t\tv = (0xffff & rnd) * wnl;\r\n\t\tw += (DW * f);\r\n\t\tif (w > PI2S)\r\n\t\t\tw -= PI2S;\r\n\r\n\t\tt = ((m_rFrequencyHz * 1.5f - abs(f - m_rFrequencyHz / 2.0f)) / (m_rFrequencyHz * 1.5f));\r\n\t\tv += sin(w) * nl * t * t * t;\r\n\r\n\t\tif (bNC)\r\n\t\t{\r\n\t\t\tif (0 >= --NC)\r\n\t\t\t{\r\n\t\t\t\tbNC = !bNC;\r\n\t\t\t\tNC = rnd * 25;\r\n\t\t\t}\r\n\r\n\t\t\tt = sin(DW * 50 * m_nTimeAxis) * 10000;\r\n\t\t\tv += (abs(t) > nl / 2 ? nl / 2 : t);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tif (0 >= --NC)\r\n\t\t\t{\r\n\t\t\t\tbNC = !bNC;\r\n\t\t\t\tNC = rnd * 20;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t*(((short int *)lpvPtr) + i) = (short int)v; //(32767 < v ? 32767 : (-32767 > v ? -32767 : v));\r\n\t}\r\n}\r\n\r\nBOOL CSinSound::InitBufferFormat()\r\n{\r\n\tm_oBgBufferDesc.dwSize = sizeof(DSBUFFERDESC);\r\n\tm_oBgBufferDesc.dwFlags = DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME \r\n\t\t| DSBCAPS_CTRLFREQUENCY | DSBCAPS_GLOBALFOCUS;\r\n\t//DSBCAPS_STATIC | DSBCAPS_GLOBALFOCUS;\r\n\tm_oBgBufferDesc.dwBufferBytes = 2 * m_oFormat.nAvgBytesPerSec;\r\n\tm_oBgBufferDesc.lpwfxFormat = &m_oFormat;\r\n\r\n\tHRESULT hr = m_pDs->CreateSoundBuffer(&m_oBgBufferDesc, &m_pBgDsb, NULL);\r\n\tif (m_bFormatValid = SUCCEEDED(hr))\r\n\t{\r\n\t\tPlayBackground();\r\n\t\treturn InitPlayedBuffer();\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nBOOL CSinSound::InitPlayedBuffer()\r\n{\r\n\tHRESULT hr; \r\n\r\n\tm_oPlayedBufferDesc.dwSize = sizeof(DSBUFFERDESC); \r\n\tm_oPlayedBufferDesc.dwFlags = DSBCAPS_STATIC | DSBCAPS_GLOBALFOCUS | DSBCAPS_CTRLVOLUME; \r\n\tm_oPlayedBufferDesc.dwBufferBytes = (DWORD)(m_rBufferLengthMs * m_oFormat.nAvgBytesPerSec / 1000); \r\n\tm_oPlayedBufferDesc.lpwfxFormat = &m_oFormat;\r\n\t\r\n\thr = m_pDs->CreateSoundBuffer(&m_oPlayedBufferDesc, &m_pDsb, NULL);\r\n\tif (m_bDsbValid = SUCCEEDED(hr))\r\n\t\treturn WriteBuffer();\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nBOOL CSinSound::WriteBuffer()\r\n{\r\n\tLPVOID  lpvPtr1; \r\n\tDWORD dwBytes1; \r\n\r\n\tHRESULT hr = m_pDsb->Lock(0, m_oPlayedBufferDesc.dwBufferBytes, &lpvPtr1, &dwBytes1, NULL, NULL, 0); \r\n\r\n\t// If the buffer was lost, restore and retry lock. \r\n\r\n\tif (DSERR_BUFFERLOST == hr) \r\n\t{ \r\n\t\tm_pDsb->Restore(); \r\n\t\thr = m_pDsb->Lock(0, m_oPlayedBufferDesc.dwBufferBytes, &lpvPtr1, &dwBytes1, NULL, NULL, DSBLOCK_ENTIREBUFFER); \r\n\t}\r\n\r\n\tif (FAILED(hr))\r\n\t\treturn (m_bDataValid = FALSE);\r\n\t\r\n\tDWORD nBytesPerSample = m_oFormat.wBitsPerSample / 8;\r\n\r\n\tfor (DWORD i = 0; i < dwBytes1 / nBytesPerSample; ++i)\r\n\t{\r\n\t\tREAL v = sin(DW * i * m_rFrequencyHz) * m_rScale;\t// -1.0 ~ +1.0\r\n\r\n\t\tfor (DWORD j = 0; j < m_oFormat.nChannels; ++j)\r\n\t\t{\r\n\t\t\tif (16 == m_oFormat.wBitsPerSample)\r\n\t\t\t{\r\n\t\t\t\t*(((short int *)lpvPtr1) + i * m_oFormat.nChannels + j) = (short int)(v * 32767);\r\n\t\t\t}\r\n\t\t\telse if (8 == m_oFormat.wBitsPerSample)\r\n\t\t\t{\r\n\t\t\t\t*(((char *)lpvPtr1) + i * m_oFormat.nChannels + j) = (char)(v * 255);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\treturn (m_bDataValid = FALSE);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn (m_bDataValid = SUCCEEDED(m_pDsb->Unlock(lpvPtr1, dwBytes1, NULL, NULL)));\r\n}\r\n\r\nvoid CSinSound::Play()\r\n{\r\n\tm_pDsb->SetCurrentPosition(0);\r\n\tHRESULT hr = m_pDsb->Play(0, 0, DSBPLAY_LOOPING);\r\n\tif (DSERR_BUFFERLOST == hr)\r\n\t{\r\n\t\tm_pDsb->Restore();\r\n\t\tWriteBuffer();\r\n\t\tm_pDsb->Play(0, 0, DSBPLAY_LOOPING);\r\n\t}\r\n}\r\n\r\nvoid CSinSound::Stop()\r\n{\r\n\tm_pDsb->Stop();\r\n}\r\n\r\nvoid CSinSound::PlayBackground()\r\n{\r\n\tHRESULT hr = m_pBgDsb->Play(0, 0, DSBPLAY_LOOPING);\r\n\tif (DSERR_BUFFERLOST == hr)\r\n\t{\r\n\t\tm_pBgDsb->Restore();\r\n\t\tm_pBgDsb->Play(0, 0, DSBPLAY_LOOPING);\r\n\t}\r\n}\r\n\r\nvoid CSinSound::StopBackground()\r\n{\r\n\tm_pBgDsb->Stop();\r\n}\r\n\r\nvoid CSinSound::SetSampleRate(DWORD nSamplesPerSec)\r\n{\r\n\tif (m_oFormat.nSamplesPerSec != nSamplesPerSec)\r\n\t{\r\n\t\tm_oFormat.nSamplesPerSec = nSamplesPerSec;\r\n\t\tm_oFormat.nAvgBytesPerSec = m_oFormat.nSamplesPerSec * (m_oFormat.wBitsPerSample / 8) * m_oFormat.nChannels;\r\n\t\tDW = 2 * PI / nSamplesPerSec;\r\n\t\tm_bFormatValid = FALSE;\r\n\t}\r\n}\r\n\r\nvoid CSinSound::SetBitsPerSample(WORD nBits)\r\n{\r\n\tif (m_oFormat.wBitsPerSample != nBits)\r\n\t{\r\n\t\tm_oFormat.wBitsPerSample = nBits;\r\n\t\tm_oFormat.nAvgBytesPerSec = m_oFormat.nSamplesPerSec * (m_oFormat.wBitsPerSample / 8) * m_oFormat.nChannels;\r\n\t\tm_bFormatValid = FALSE;\r\n\t}\r\n}\r\n\r\nvoid CSinSound::SetBufferLength(REAL rMSec)\r\n{\r\n\tif (m_rBufferLengthMs != rMSec)\r\n\t{\r\n\t\tm_rBufferLengthMs = rMSec;\r\n\t\tm_bDsbValid = FALSE;\r\n\t}\r\n}\r\n\r\nvoid CSinSound::SetFrequency(REAL rFrequency)\r\n{\r\n\tif (m_rFrequencyHz != rFrequency)\r\n\t{\r\n\t\tREAL w = 1.0f / (REAL)rFrequency;\r\n\t\tREAL d = 1.0f / (REAL)m_oFormat.nSamplesPerSec;\r\n\t\tint nTimes;\r\n\t\tfor (nTimes = 100; nTimes <= 1000; ++nTimes)\r\n\t\t{\r\n\t\t\tREAL rRemScale = fmod(w * nTimes, d) / w;\r\n\r\n\t\t\tif (rRemScale < 0.001l || rRemScale > 0.998l)\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tm_rFrequencyHz = rFrequency;\r\n\t\tm_rBufferLengthMs = nTimes * w * 1000.0f;\r\n\t\tm_bDsbValid = FALSE;\r\n\t}\r\n}\r\n\r\nvoid CSinSound::SetScale(REAL rScale)\r\n{\r\n\tif (m_rScale != rScale)\r\n\t{\r\n\t\tm_rScale = rScale;\r\n\t\tm_rNoiseScale = rScale * 0.25f;\r\n\t\tm_bDataValid = FALSE;\r\n\t}\r\n}\r\n\r\nBOOL CSinSound::Validate()\r\n{\r\n\tif (!m_bFormatValid)\r\n\t{\r\n\t\tm_pDsb->Release(); m_pDsb = NULL;\r\n\t\tm_pBgDsb->Release(); m_pBgDsb = NULL;\r\n\t\treturn InitBufferFormat();\r\n\t}\r\n\telse if (!m_bDsbValid)\r\n\t{\r\n\t\tm_pDsb->Release(); m_pDsb = NULL;\r\n\t\treturn InitPlayedBuffer();\r\n\t}\r\n\telse if (!m_bDataValid)\r\n\t{\r\n\t\treturn WriteBuffer();\r\n\t}\r\n\r\n\treturn true;\r\n}\r\n\r\nvoid CSinSound::SetVolume(LONG nAtte)\r\n{\r\n\tHRESULT h = m_pDsb->SetVolume(nAtte);\r\n\t//h = m_pBgDsb->SetVolume(nAtte);\r\n}\r\n\r\nLONG CSinSound::GetVolume()\r\n{\r\n\tLONG r = -1;\r\n\tm_pDsb->GetVolume(&r);\r\n\treturn r;\r\n}\r\n\r\nvoid CSinSound::SetNoiseVolume(LONG nAtte)\r\n{\r\n\tm_pBgDsb->SetVolume(nAtte);\r\n}\r\n\r\nLONG CSinSound::GetNoiseVolume()\r\n{\r\n\tLONG r = -1;\r\n\tm_pBgDsb->GetVolume(&r);\r\n\treturn r;\r\n}\r\n\r\nvoid CSinSound::SetNoise(BOOL bOn)\r\n{\r\n\tm_bNoiseOn = bOn;\r\n}\r\n"
  },
  {
    "path": "src/SinSound.h",
    "content": "#pragma once\r\n\r\n#include \"EventManagerWin32.h\"\r\n\r\n#define PI\t\t\t\t3.1415926f\r\n#define PI2S\t\t\t2 * PI\r\ntypedef float\t\t\tREAL;\r\n\r\nclass CSinSound : public ITimerEventControl\r\n{\r\npublic:\r\n\tCSinSound();\r\n\t~CSinSound();\r\n\r\n\tBOOL Initialize(HWND hWnd);\r\n\r\n\tvoid SetSampleRate(DWORD nSamplesPerSec);\r\n\tDWORD GetSampleRate() { return m_oFormat.nSamplesPerSec; };\r\n\r\n\tvoid SetBitsPerSample(WORD nBits);\r\n\tWORD GetBitsPerSample() { return m_oFormat.wBitsPerSample; };\r\n\r\n\tvoid SetBufferLength(REAL rMSec);\r\n\tREAL GetBufferLength() { return m_rBufferLengthMs; };\r\n\r\n\tvoid SetFrequency(REAL rFrequency);\r\n\tREAL GetFrequency() { return m_rFrequencyHz; };\r\n\r\n\tvoid SetScale(REAL rScale);\r\n\tREAL GetScale() { return m_rScale; };\r\n\r\n\tvoid SetVolume(LONG rVol);\r\n\tLONG GetVolume();\r\n\r\n\tvoid SetNoiseVolume(LONG rVol);\r\n\tLONG GetNoiseVolume();\r\n\r\n\tBOOL Validate();\r\n\tvoid Play();\r\n\tvoid Stop();\r\n\r\n\tvoid PlayBackground();\r\n\tvoid StopBackground();\r\n\r\n\tvoid SetNoise(BOOL bOn);\r\n\tBOOL GetNoise() { return m_bNoiseOn; };\r\n\r\n\tvirtual BOOL OnTimer(void* owner, int nTimerId);\r\n\r\nprivate:\r\n\r\n\tBOOL InitBufferFormat();\r\n\tBOOL InitPlayedBuffer();\r\n\tBOOL WriteBuffer();\r\n\tBOOL InitNoiseBuffer();\r\n\tvoid FillBackground();\r\n\tvoid FillNoises(LPVOID lpvPtr, DWORD nBytes);\r\n\tvoid FillBlank(LPVOID lpvPtr, DWORD nBytes);\r\n\r\n\tLPDIRECTSOUND\t\tm_pDs;\r\n\tLPDIRECTSOUNDBUFFER m_pBgDsb;\r\n\tLPDIRECTSOUNDBUFFER\tm_pDsb;\r\n\r\n\tWAVEFORMATEX\t\tm_oFormat;\r\n\tDSBUFFERDESC\t\tm_oPlayedBufferDesc;\r\n\tDSBUFFERDESC\t\tm_oBgBufferDesc;\r\n\r\n\tDWORD\t\t\t\tm_nLastEnd;\r\n\tDWORD\t\t\t\tm_nTimeAxis;\r\n\r\n\tREAL\t\t\t\tm_rBufferLengthMs;\r\n\tREAL\t\t\t\tm_rFrequencyHz;\r\n\tREAL\t\t\t\tm_rScale;\r\n\tREAL\t\t\t\tm_rNoiseScale;\r\n\r\n\tBOOL\t\t\t\tm_bFormatValid;\r\n\tBOOL\t\t\t\tm_bDsbValid;\r\n\tBOOL\t\t\t\tm_bDataValid;\r\n\r\n\tBOOL\t\t\t\tm_bNoiseOn;\r\n};\r\n"
  },
  {
    "path": "src/UpgradeLog.XML",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><?xml-stylesheet type='text/xsl' href='_UpgradeReport_Files/UpgradeReport.xslt'?><UpgradeLog>\r\n<Properties><Property Name=\"Solution\" Value=\"Lakey\">\r\n</Property><Property Name=\"Solution File\" Value=\"D:\\download\\V1.0.build.0005.source\\source\\Lakey.sln\">\r\n</Property><Property Name=\"User Options File\" Value=\"D:\\download\\V1.0.build.0005.source\\source\\Lakey.suo\">\r\n</Property><Property Name=\"Date\" Value=\"2007年6月3日\">\r\n</Property><Property Name=\"Time\" Value=\"8:40\">\r\n</Property></Properties><Event ErrorLevel=\"0\" Project=\"\" Source=\"Lakey.sln\" Description=\"File successfully backed up as D:\\download\\V1.0.build.0005.source\\source\\Lakey.sln.old\">\r\n</Event><Event ErrorLevel=\"0\" Project=\"\" Source=\"Lakey.suo\" Description=\"File successfully backed up as D:\\download\\V1.0.build.0005.source\\source\\Lakey.suo.old\">\r\n</Event><Event ErrorLevel=\"0\" Project=\"Lakey\" Source=\"Lakey.vcproj\" Description=\"Visual C++ now provides improved safety in its C and C++ Libraries. This includes new and improved functions, additional checking and validation, and internal design changes. These libraries are turned on by default. You may see some warnings about unsafe functions or parameters when you build your project. The warnings will generally suggest an alternative safer coding style or function. It is advised that you correct these warnings, in order to make your code more safe. Full details can be found in the documentation by searching for 'Security Enhancements in the CRT' and for 'Checked Iterators'.\">\r\n</Event><Event ErrorLevel=\"0\" Project=\"Lakey\" Source=\"Lakey.vcproj\" Description=\"The C/C++ compiler default settings have been modified to be more compliant with ISO Standard C++. Included in those changes are enforcing Standard C++ for loop scoping and supporting wchar_t as a native type. These changes may cause existing code to no longer compile without changes to the code or the compiler options with which it is built.\">\r\n</Event><Event ErrorLevel=\"0\" Project=\"Lakey\" Source=\"Lakey.vcproj\" Description=\"The single-threaded run-time library switches (/MLd, /ML) have been removed from the C++ compiler.  The project has been automatically converted to use the corresponding multi-threaded run-time library switches (/MTd, /MT).\">\r\n</Event><Event ErrorLevel=\"1\" Project=\"Lakey\" Source=\"Lakey.vcproj\" Description=\"Due to the requirement that Visual C++ projects produce an embedded (by default) Windows SxS manifest, manifest files in the project are automatically excluded from building with the Manifest Tool.  It is recommended that the dependency information contained in any manifest files be converted to &quot;#pragma comment(linker,&quot;&lt;insert dependency here&gt;&quot;)&quot; in a header file that is included from your source code.  If your project already embeds a manifest in the RT_MANIFEST resource section through a resource (.rc) file, the line will need to be commented out before the project will build correctly.\">\r\n</Event><Event ErrorLevel=\"1\" Project=\"Lakey\" Source=\"Lakey.vcproj\" Description=\"Due to a conformance change in the C++ compiler, code change may be required before your project will build without errors.  Previous versions of the C++ compiler allowed specification of member function pointers by member function name (e.g. MemberFunctionName).  The C++ standard requires a fully qualified name with the use of the address-of operator (e.g. &amp;ClassName::MemberFunctionName).  If your project contains forms or controls used in the Windows Forms Designer, you may have to change code in InitializeComponent because the designer generated code used the non-conformant syntax in delegate construction (used in event handlers).\">\r\n</Event><Event ErrorLevel=\"0\" Project=\"Lakey\" Source=\"Lakey.vcproj\" Description=\"Project file successfully backed up as 'D:\\download\\V1.0.build.0005.source\\source\\Lakey.vcproj.7.00.old'.\">\r\n</Event><Event ErrorLevel=\"0\" Project=\"Lakey\" Source=\"Lakey.vcproj\" Description=\"Project upgraded successfully.\">\r\n</Event><Event ErrorLevel=\"3\" Project=\"Lakey\" Source=\"Lakey.vcproj\" Description=\"Converted\">\r\n</Event><Event ErrorLevel=\"0\" Project=\"\" Source=\"Lakey.sln\" Description=\"Solution converted successfully\">\r\n</Event><Event ErrorLevel=\"3\" Project=\"\" Source=\"Lakey.sln\" Description=\"Converted\">\r\n</Event></UpgradeLog>"
  },
  {
    "path": "src/UpgradeLog2.XML",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><?xml-stylesheet type='text/xsl' href='_UpgradeReport_Files/UpgradeReport.xslt'?><UpgradeLog>\r\n<Properties><Property Name=\"Solution\" Value=\"Lakey\">\r\n</Property><Property Name=\"Solution File\" Value=\"\\\\psf\\Home\\Documents\\Visual Studio 2010\\Projects\\lakey\\Lakey.sln\">\r\n</Property><Property Name=\"Date\" Value=\"2012年6月3日\">\r\n</Property><Property Name=\"Time\" Value=\"11:52\">\r\n</Property><Property Name=\"Log Number\" Value=\"2\">\r\n</Property></Properties><Event ErrorLevel=\"0\" Project=\"Lakey\" Source=\"Lakey.vcproj\" Description=\"Converting project file '\\\\psf\\Home\\Documents\\Visual Studio 2010\\Projects\\lakey\\Lakey.vcproj'.\">\r\n</Event><Event ErrorLevel=\"1\" Project=\"Lakey\" Source=\"Lakey.vcproj\" Description=\"This application has been updated to include settings related to the User Account Control (UAC) feature of Windows Vista. By default, when run on Windows Vista with UAC enabled, this application is marked to run with the same privileges as the process that launched it. This marking also disables the application from running with virtualization. You can change UAC related settings from the Property Pages of the project.\">\r\n</Event><Event ErrorLevel=\"1\" Project=\"Lakey\" Source=\"Lakey.vcproj\" Description=\"VCWebServiceProxyGeneratorTool is no longer supported. The tool has been removed from your project settings.\">\r\n</Event><Event ErrorLevel=\"1\" Project=\"Lakey\" Source=\"Lakey.vcproj\" Description=\"Attribute 'Detect64BitPortabilityProblems' of 'VCCLCompilerTool' is not supported in this version and has been removed during conversion.\">\r\n</Event><Event ErrorLevel=\"0\" Project=\"Lakey\" Source=\"Lakey.vcproj\" Description=\"Web deployment to the local IIS server is no longer supported. The Web Deployment build tool has been removed from your project settings.\">\r\n</Event><Event ErrorLevel=\"1\" Project=\"Lakey\" Source=\"Lakey.vcproj\" Description=\"Attribute 'Detect64BitPortabilityProblems' of 'VCCLCompilerTool' is not supported in this version and has been removed during conversion.\">\r\n</Event><Event ErrorLevel=\"0\" Project=\"Lakey\" Source=\"Lakey.vcproj\" Description=\"Done converting to new project file '\\\\psf\\Home\\Documents\\Visual Studio 2010\\Projects\\lakey\\Lakey.vcxproj'.\">\r\n</Event><Event ErrorLevel=\"3\" Project=\"Lakey\" Source=\"Lakey.vcproj\" Description=\"Converted\">\r\n</Event><Event ErrorLevel=\"0\" Project=\"\" Source=\"Lakey.sln\" Description=\"Solution converted successfully\">\r\n</Event><Event ErrorLevel=\"3\" Project=\"\" Source=\"Lakey.sln\" Description=\"Converted\">\r\n</Event></UpgradeLog>"
  },
  {
    "path": "src/UpgradeLog3.XML",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><?xml-stylesheet type='text/xsl' href='_UpgradeReport_Files/UpgradeReport.xslt'?><UpgradeLog>\r\n<Properties><Property Name=\"Solution\" Value=\"Lakey\">\r\n</Property><Property Name=\"Solution File\" Value=\"\\\\psf\\Home\\Documents\\Visual Studio 2010\\Projects\\lakey\\Lakey.sln\">\r\n</Property><Property Name=\"Date\" Value=\"2012年6月3日\">\r\n</Property><Property Name=\"Time\" Value=\"16:44:36\">\r\n</Property><Property Name=\"Log Number\" Value=\"3\">\r\n</Property></Properties><Event ErrorLevel=\"0\" Project=\"Lakey\" Source=\"Lakey.vcproj\" Description=\"Converting project file '\\\\psf\\Home\\Documents\\Visual Studio 2010\\Projects\\lakey\\Lakey.vcproj'.\">\r\n</Event><Event ErrorLevel=\"1\" Project=\"Lakey\" Source=\"Lakey.vcproj\" Description=\"This application has been updated to include settings related to the User Account Control (UAC) feature of Windows Vista. By default, when run on Windows Vista with UAC enabled, this application is marked to run with the same privileges as the process that launched it. This marking also disables the application from running with virtualization. You can change UAC related settings from the Property Pages of the project.\">\r\n</Event><Event ErrorLevel=\"1\" Project=\"Lakey\" Source=\"Lakey.vcproj\" Description=\"VCWebServiceProxyGeneratorTool is no longer supported. The tool has been removed from your project settings.\">\r\n</Event><Event ErrorLevel=\"1\" Project=\"Lakey\" Source=\"Lakey.vcproj\" Description=\"Attribute 'Detect64BitPortabilityProblems' of 'VCCLCompilerTool' is not supported in this version and has been removed during conversion.\">\r\n</Event><Event ErrorLevel=\"0\" Project=\"Lakey\" Source=\"Lakey.vcproj\" Description=\"Web deployment to the local IIS server is no longer supported. The Web Deployment build tool has been removed from your project settings.\">\r\n</Event><Event ErrorLevel=\"1\" Project=\"Lakey\" Source=\"Lakey.vcproj\" Description=\"Attribute 'Detect64BitPortabilityProblems' of 'VCCLCompilerTool' is not supported in this version and has been removed during conversion.\">\r\n</Event><Event ErrorLevel=\"0\" Project=\"Lakey\" Source=\"Lakey.vcproj\" Description=\"Done converting to new project file '\\\\psf\\Home\\Documents\\Visual Studio 2010\\Projects\\lakey\\Lakey.vcxproj'.\">\r\n</Event><Event ErrorLevel=\"3\" Project=\"Lakey\" Source=\"Lakey.vcproj\" Description=\"Converted\">\r\n</Event></UpgradeLog>"
  },
  {
    "path": "src/html1.htm",
    "content": ""
  },
  {
    "path": "src/lakey.ini",
    "content": "[CW]\r\nbeepfreq=1000.000000\r\nbeepvol=0.250000\r\nshorthit=80\r\nlonghit=240\r\nhitdelay=80\r\nletterdelay=240\r\nworddelay=240\r\n[GLOBAL]\r\nwindowrect=53,64,989,514\r\n[JOURNAL]\r\nsendperiod=27\r\nsendidlelimit=750\r\nsendrect=5,235,490,267\r\nsendlabeloffset=0,-15\r\nsendlabel=Send\r\nsendqueuerect=5,270,490,281\r\nspecrect=498,10,908,160\r\nspeclabeloffset=0,-15\r\nspeclabel=Spectrogram\r\nrecvperiod=27\r\nrecvidlelimit=750\r\nrecvrect=5,180,490,212\r\nrecvlabeloffset=0,-15\r\nrecvlabel=Recieve\r\nrecvmrect=8,10,493,160\r\nrecvanalyzesamples=512\r\nrecvthreshold=0.300000\r\nrecvfreqstart=850\r\nrecvfreqend=1250\r\n[MAINPANEL]\r\ncw=500,290,400,92,000D,CW\r\nsendpause=603,265,91,16,0074,Pause,Continue\r\nsendfile=500,265,91,16,0075,File...\r\nautokeyswitch=706,265,91,16,0009,Manual,Auto(L/R),Auto(R/L)\r\nnoiseswitch=809,265,91,16,0076,Disturb\r\nsendvol=500,168,90,90,-80.000000,0.000000,0.000000,Volumn(dB)\r\nnoisevol=809,168,90,90,-80.000000,0.000000,0.000000,Disturb(dB)\r\nsendspeed=603,168,90,90,5.000000,30.000000,20.000000,Speed(wpm)\r\nspecbrightness=706,168,90,90,-60.000000,60.000000,0.000000,Spectrogram(dB)\r\n[KOCH]\r\ncharlist=\r\nkoch_wordlen=5\r\n[MORSE]\r\nA=00000002,00000003,0041\r\nB=00000007,0000000F,0042\r\nC=00000005,0000000F,0043\r\nD=00000003,00000007,0044\r\nE=00000001,00000001,0045\r\nF=0000000D,0000000F,0046\r\nG=00000001,00000007,0047\r\nH=0000000F,0000000F,0048\r\nI=00000003,00000003,0049\r\nJ=00000008,0000000F,004A\r\nK=00000002,00000007,004B\r\nL=0000000B,0000000F,004C\r\nM=00000000,00000003,004D\r\nN=00000001,00000003,004E\r\nO=00000000,00000007,004F\r\nP=00000009,0000000F,0050\r\nQ=00000002,0000000F,0051\r\nR=00000005,00000007,0052\r\nS=00000007,00000007,0053\r\nT=00000000,00000001,0054\r\nU=00000006,00000007,0055\r\nV=0000000E,0000000F,0056\r\nW=00000004,00000007,0057\r\nX=00000006,0000000F,0058\r\nY=00000004,0000000F,0059\r\nZ=00000003,0000000F,005A\r\n1=00000010,0000001F,0031\r\n2=00000018,0000001F,0032\r\n3=0000001C,0000001F,0033\r\n4=0000001E,0000001F,0034\r\n5=0000001F,0000001F,0035\r\n6=0000000F,0000001F,0036\r\n7=00000007,0000001F,0037\r\n8=00000003,0000001F,0038\r\n9=00000001,0000001F,0039\r\n0=00000000,0000001F,0030\r\n?=00000033,0000003F,0000\r\n/=0000000D,0000001F,006F\r\n(=00000012,0000003F,0000\r\n-=0000000E,0000003F,006D\r\n.=0000002A,0000003F,006E\r\n_=00000000,00000000,0020\r\n[HWCTRL]\r\nenableextport=00000000\r\nextportaddr=00000378\r\nopenbyte=000000FF\r\nclosebyte=00000000\r\n[NETWORK]\r\nnwenabled=1\r\nlocalport=3010\r\nhosts=0\r\n"
  },
  {
    "path": "src/lakey_EN.ini",
    "content": "[CW]\r\nbeepfreq=1000.000000\r\nbeepvol=0.250000\r\nshorthit=80\r\nlonghit=240\r\nhitdelay=80\r\nletterdelay=240\r\nworddelay=240\r\n[GLOBAL]\r\nwindowrect=212,207,1132,643\r\n[JOURNAL]\r\nsendperiod=27\r\nsendidlelimit=750\r\nsendrect=5,235,490,267\r\nsendlabeloffset=0,-15\r\nsendlabel=Send\r\nsendqueuerect=5,270,490,281\r\nspecrect=498,10,908,160\r\nspeclabeloffset=0,-15\r\nspeclabel=Spectrogram\r\nrecvperiod=27\r\nrecvidlelimit=750\r\nrecvrect=5,180,490,212\r\nrecvlabeloffset=0,-15\r\nrecvlabel=Recieve\r\nrecvmrect=8,10,493,160\r\nrecvanalyzesamples=256\r\nrecvthreshold=0.300000\r\nrecvfreqstart=850\r\nrecvfreqend=1250\r\n[MAINPANEL]\r\ncw=500,290,297,92,000D,CW\r\nsendpause=603,265,91,16,0074,Pause,Continue\r\nsendfile=500,265,91,16,0075,File...\r\nautokeyswitch=706,265,91,16,0009,Manual,Auto(L/R),Auto(R/L)\r\nnoiseswitch=809,265,91,16,0076,Disturb\r\nsendvol=500,168,90,90,-80.000000,0.000000,0.000000,Send Vol(dB)\r\nnoisevol=809,168,90,90,-80.000000,0.000000,0.000000,Disturb Vol(dB)\r\nsendspeed=603,168,90,90,5.000000,30.000000,20.000000,Speed(wpm)\r\nspecbrightness=706,168,90,90,-60.000000,60.000000,10.312500,Spec Gain(dB)\r\n[KOCH]\r\ncharlist=KMRSUAPTLOWI.NJEF0Y,VG5/Q9ZH38B?427C1D6X\u0005\u0005\u0005\u0005\u0005\u0005\u0005\u0005\rkoch_wordlen=5\r\n[MORSE]\r\nA=00000002,00000003,0041\r\nB=00000007,0000000F,0042\r\nC=00000005,0000000F,0043\r\nD=00000003,00000007,0044\r\nE=00000001,00000001,0045\r\nF=0000000D,0000000F,0046\r\nG=00000001,00000007,0047\r\nH=0000000F,0000000F,0048\r\nI=00000003,00000003,0049\r\nJ=00000008,0000000F,004A\r\nK=00000002,00000007,004B\r\nL=0000000B,0000000F,004C\r\nM=00000000,00000003,004D\r\nN=00000001,00000003,004E\r\nO=00000000,00000007,004F\r\nP=00000009,0000000F,0050\r\nQ=00000002,0000000F,0051\r\nR=00000005,00000007,0052\r\nS=00000007,00000007,0053\r\nT=00000000,00000001,0054\r\nU=00000006,00000007,0055\r\nV=0000000E,0000000F,0056\r\nW=00000004,00000007,0057\r\nX=00000006,0000000F,0058\r\nY=00000004,0000000F,0059\r\nZ=00000003,0000000F,005A\r\n1=00000010,0000001F,0031\r\n2=00000018,0000001F,0032\r\n3=0000001C,0000001F,0033\r\n4=0000001E,0000001F,0034\r\n5=0000001F,0000001F,0035\r\n6=0000000F,0000001F,0036\r\n7=00000007,0000001F,0037\r\n8=00000003,0000001F,0038\r\n9=00000001,0000001F,0039\r\n0=00000000,0000001F,0030\r\n?=00000033,0000003F,0000\r\n/=0000000D,0000001F,006F\r\n(=00000012,0000003F,0000\r\n)=00000012,0000003F,0000\r\n-=0000000E,0000003F,006D\r\n.=0000002A,0000003F,006E\r\n_=00000000,00000000,0020\r\n[HWCTRL]\r\nenableextport=00000000\r\nextportaddr=00000378\r\nopenbyte=000000FF\r\nclosebyte=00000000\r\n[NETWORK]\r\nnwenabled=1\r\nlocalport=3010\r\nhosts=0\r\n"
  },
  {
    "path": "src/lakey_ZH.ini",
    "content": "[CW]\r\nbeepfreq=1000.000000\r\nbeepvol=0.250000\r\nshorthit=80\r\nlonghit=240\r\nhitdelay=80\r\nletterdelay=240\r\nworddelay=240\r\n[GLOBAL]\r\nwindowrect=224,104,1144,540\r\n[JOURNAL]\r\nsendperiod=27\r\nsendidlelimit=750\r\nsendrect=5,235,490,267\r\nsendlabeloffset=0,-15\r\nsendlabel=Send\r\nsendqueuerect=5,270,490,281\r\nspecrect=498,10,908,160\r\nspeclabeloffset=0,-15\r\nspeclabel=Spectrogram\r\nrecvperiod=27\r\nrecvidlelimit=750\r\nrecvrect=5,180,490,212\r\nrecvlabeloffset=0,-15\r\nrecvlabel=Recieve\r\nrecvmrect=8,10,493,160\r\nrecvanalyzesamples=512\r\nrecvthreshold=0.300000\r\nrecvfreqstart=850\r\nrecvfreqend=1250\r\n[MAINPANEL]\r\ncw=500,290,297,92,000D,CW\r\nsendpause=603,265,91,16,0074,ͣ,\r\nsendfile=500,265,91,16,0075,ļ...\r\nautokeyswitch=706,265,91,16,0009,ֶ,Զ(/),Զ(/)\r\nnoiseswitch=809,265,91,16,0076,\r\nsendvol=500,168,90,90,-80.000000,0.000000,-15.312500,(dB)\r\nnoisevol=809,168,90,90,-80.000000,0.000000,0.000000,(dB)\r\nsendspeed=603,168,90,90,5.000000,30.000000,20.000000,ٶ(wpm)\r\nspecbrightness=706,168,90,90,-60.000000,60.000000,55.781250,Ƶ(dB)\r\n[KOCH]\r\ncharlist=KMRSUAPTLOWI.NJEF0Y,VG5/Q9ZH38B?427C1D6X\u0005\u0005\u0005\u0005\u0005\u0005\u0005\u0005\rkoch_wordlen=5\r\n[MORSE]\r\nA=00000002,00000003,0041\r\nB=00000007,0000000F,0042\r\nC=00000005,0000000F,0043\r\nD=00000003,00000007,0044\r\nE=00000001,00000001,0045\r\nF=0000000D,0000000F,0046\r\nG=00000001,00000007,0047\r\nH=0000000F,0000000F,0048\r\nI=00000003,00000003,0049\r\nJ=00000008,0000000F,004A\r\nK=00000002,00000007,004B\r\nL=0000000B,0000000F,004C\r\nM=00000000,00000003,004D\r\nN=00000001,00000003,004E\r\nO=00000000,00000007,004F\r\nP=00000009,0000000F,0050\r\nQ=00000002,0000000F,0051\r\nR=00000005,00000007,0052\r\nS=00000007,00000007,0053\r\nT=00000000,00000001,0054\r\nU=00000006,00000007,0055\r\nV=0000000E,0000000F,0056\r\nW=00000004,00000007,0057\r\nX=00000006,0000000F,0058\r\nY=00000004,0000000F,0059\r\nZ=00000003,0000000F,005A\r\n1=00000010,0000001F,0031\r\n2=00000018,0000001F,0032\r\n3=0000001C,0000001F,0033\r\n4=0000001E,0000001F,0034\r\n5=0000001F,0000001F,0035\r\n6=0000000F,0000001F,0036\r\n7=00000007,0000001F,0037\r\n8=00000003,0000001F,0038\r\n9=00000001,0000001F,0039\r\n0=00000000,0000001F,0030\r\n?=00000033,0000003F,0000\r\n/=0000000D,0000001F,006F\r\n(=00000012,0000003F,0000\r\n)=00000012,0000003F,0000\r\n-=0000000E,0000003F,006D\r\n.=0000002A,0000003F,006E\r\n_=00000000,00000000,0020\r\n[HWCTRL]\r\nenableextport=00000000\r\nextportaddr=00000378\r\nopenbyte=000000FF\r\nclosebyte=00000000\r\n[NETWORK]\r\nnwenabled=1\r\nlocalport=3010\r\nhosts=0\r\n"
  },
  {
    "path": "src/mc.txt",
    "content": "A=10,VK_A\r\nB=0111\r\nC=0101\r\nD=011\r\nE=1\r\nF=1101\r\nG=001\r\nH=1111\r\nI=11\r\nJ=1000\r\nK=010\r\nL=1011\r\nM=00\r\nN=01\r\nO=000\r\nP=1001\r\nQ=0010\r\nR=101\r\nS=111\r\nT=0\r\nU=110\r\nV=1110\r\nW=100\r\nX=0110\r\nY=0100\r\nZ=0011\r\n?=110011\r\n/=01101\r\n(=010010\r\n)=010010\r\n-=01110\r\n.=101010\r\n1=10000\r\n2=11000\r\n3=11100\r\n4=1111\r\n5=11111\r\n6=01111\r\n7=00111\r\n8=00011\r\n9=00001\r\n0=00000"
  },
  {
    "path": "src/mytest.cpp",
    "content": "#include \"stdafx.h\"\r\n\r\n#include <windows.h>\r\n#include <winioctl.h>\r\n#include <stdio.h>\r\n\r\n#include \"mytest.h\"\r\n\r\nBOOL GetDriveGeometry(DISK_GEOMETRY *pdg)\r\n{\r\n  HANDLE hDevice;               // handle to the drive to be examined \r\n  BOOL bResult;                 // results flag\r\n  DWORD junk;                   // discard results\r\n\r\n  hDevice = CreateFile(\"\\\\\\\\.\\\\PhysicalDrive0\",  // drive to open\r\n                    0,                // no access to the drive\r\n                    FILE_SHARE_READ | // share mode\r\n                    FILE_SHARE_WRITE, \r\n                    NULL,             // default security attributes\r\n                    OPEN_EXISTING,    // disposition\r\n                    0,                // file attributes\r\n                    NULL);            // do not copy file attributes\r\n\r\n  if (hDevice == INVALID_HANDLE_VALUE) // cannot open the drive\r\n  {\r\n    return (FALSE);\r\n  }\r\n\r\n  bResult = DeviceIoControl(hDevice,  // device to be queried\r\n      IOCTL_DISK_GET_DRIVE_GEOMETRY,  // operation to perform\r\n                             NULL, 0, // no input buffer\r\n                            pdg, sizeof(*pdg),     // output buffer\r\n                            &junk,                 // # bytes returned\r\n                            (LPOVERLAPPED) NULL);  // synchronous I/O\r\n\r\n  CloseHandle(hDevice);\r\n\r\n  return (bResult);\r\n}\r\n\r\nint mytest()\r\n{\r\n  DISK_GEOMETRY pdg;            // disk drive geometry structure\r\n  BOOL bResult;                 // generic results flag\r\n  ULONGLONG DiskSize;           // size of the drive, in bytes\r\n\r\n  bResult = GetDriveGeometry (&pdg);\r\n\r\n  if (bResult) \r\n  {\r\n    printf(\"Cylinders = %I64d\\n\", pdg.Cylinders);\r\n    printf(\"Tracks/cylinder = %ld\\n\", (ULONG) pdg.TracksPerCylinder);\r\n    printf(\"Sectors/track = %ld\\n\", (ULONG) pdg.SectorsPerTrack);\r\n    printf(\"Bytes/sector = %ld\\n\", (ULONG) pdg.BytesPerSector);\r\n\r\n    DiskSize = pdg.Cylinders.QuadPart * (ULONG)pdg.TracksPerCylinder *\r\n      (ULONG)pdg.SectorsPerTrack * (ULONG)pdg.BytesPerSector;\r\n    printf(\"Disk size = %I64d (Bytes) = %I64d (Gb)\\n\", DiskSize,\r\n           DiskSize / (1024 * 1024 * 1024));\r\n  } \r\n  else \r\n  {\r\n    printf (\"GetDriveGeometry failed. Error %ld.\\n\", GetLastError ());\r\n  }\r\n\r\n  return ((int)bResult);\r\n}"
  },
  {
    "path": "src/mytest.h",
    "content": "int mytest();\r\n"
  },
  {
    "path": "src/resource.h",
    "content": "//{{NO_DEPENDENCIES}}\n// Microsoft Visual C++ generated include file.\n// Used by Lakey.rc\n//\n#define IDC_MYICON                      2\n#define IDD_LAKEY_DIALOG                102\n#define IDS_APP_TITLE                   103\n#define IDD_ABOUTBOX                    103\n#define IDM_ABOUT                       104\n#define IDD_SETTINGS                    104\n#define IDM_EXIT                        105\n#define IDI_LAKEY                       107\n#define IDI_SMALL                       108\n#define IDC_LAKEY                       109\n#define IDR_MAINFRAME                   128\n#define ID_129                          129\n#define IDB_BITMAP1                     131\n#define IDB_LOGO                        131\n#define ID_KOCH                         132\n#define ID__                            133\n#define ID_KOCH_134                     134\n#define IDD_COPYPAD                     135\n#define IDD_TEST                        136\n#define IDD_GENERAL                     137\n#define IDM_TEST                        199\n#define IDC_EDIT1                       1000\n#define IDC_TONE                        1001\n#define IDC_BEEPFREQ                    1002\n#define IDC_COPYTEXT                    1003\n#define IDC_SETTINGSTAB                 1004\n#define IDC_BEEPVOL                     1005\n#define IDM_SETTINGS                    1006\n#define IDC_SENDPERIOD                  1007\n#define IDC_BUTTON1                     1008\n#define IDC_HOSTADD                     1008\n#define IDC_SENDILDELIMIT               1009\n#define IDC_RECVPERIOD                  1010\n#define IDC_RECVILDELIMIT               1011\n#define IDC_RECVANALYZESAMPLES          1012\n#define IDC_RECVTHRESHOLD               1013\n#define IDC_RECVFREQSTART               1014\n#define IDC_RECVFREQEND                 1015\n#define IDC_HOTKEY1                     1016\n#define IDC_CALCSPEED                   1017\n#define IDC_SHORTHIT                    1018\n#define IDC_LONGHIT                     1019\n#define IDC_HITDELAY                    1020\n#define IDC_LETTERDELAY                 1021\n#define IDC_CW                          1022\n#define ID_ACCEPT                       1023\n#define IDC_ACCEPT                      1024\n#define IDC_SPEED                       1025\n#define IDC_KOCHCHARS                   1026\n#define IDC_ELAPSETIME                  1027\n#define IDC_COPIED                      1028\n#define IDC_INCORRECT                   1029\n#define IDC_CORRECTPERC                 1030\n#define IDC_RICHEDIT21                  1031\n#define IDC_LOCALPORT                   1032\n#define IDC_NWNODES                     1033\n#define IDC_HOSTPORT                    1033\n#define IDC_TAB1                        1034\n#define IDC_HOSTLIST                    1034\n#define IDC_HOSTADDR                    1035\n#define IDC_HOSTNAME                    1035\n#define IDC_HOSTDEL                     1036\n#define IDC_CHECK1                      1038\n#define IDC_NWENABLED                   1038\n#define IDM_KOCHSTART                   1051\n#define IDM_KOCHSTOP                    1052\n#define IDM_KOCHWAVE                    1053\n#define IDM_PROMPTWAVE                  1054\n#define IDM_SENDTRAINING\t\t\t\t1055\n#define IDC_KOCHWORDLEN                 1061\n#define IDC_WORDDELAY                   1062\n#define IDD_PROMPTBOX                   1065\n#define IDC_INPUTSTR                    1066\n#define IDD_SEND                        1067\n#define IDC_PROMPTTEXT                  1068\n#define IDD_RECV                        1072\n#define IDD_IO                          1073\n#define IDD_KOCH                        1074\n#define IDD_NETWORK                     1075\n#define IDD_SETTINGS2                   1076\n#define IDC_EXTPORTENABLE               1100\n#define IDC_EXTPORTADDR                 1101\n#define IDC_OPENBYTE                    1102\n#define IDC_CLOSEBYTE                   1103\n#define IDA_TEST                        32775\n#define IDC_STATIC                      -1\n\n// Next default values for new objects\n// \n#ifdef APSTUDIO_INVOKED\n#ifndef APSTUDIO_READONLY_SYMBOLS\n#define _APS_NO_MFC                     1\n#define _APS_NEXT_RESOURCE_VALUE        138\n#define _APS_NEXT_COMMAND_VALUE         32777\n#define _APS_NEXT_CONTROL_VALUE         1039\n#define _APS_NEXT_SYMED_VALUE           110\n#endif\n#endif\n"
  },
  {
    "path": "src/stdafx.cpp",
    "content": "// stdafx.cpp : ֻ׼ļԴļ\r\n// Lakey.pch ΪԤͷ\r\n// stdafx.obj ԤϢ\r\n\r\n#include \"stdafx.h\"\r\n\r\n// TODO:  STDAFX.H \r\n//κĸͷڴļ\r\n"
  },
  {
    "path": "src/stdafx.h",
    "content": "// stdafx.h : ׼ϵͳļİļ\r\n// ǳõĵĿضİļ\r\n//\r\n\r\n#pragma once\r\n\r\n//#define WIN32_LEAN_AND_MEAN\t\t//  Windows ͷųʹõ\r\n// Windows ͷļ\r\n#include <windows.h>\r\n#include <windowsx.h>\r\n\r\n// C ʱͷļ\r\n#include <stdlib.h>\r\n#include <malloc.h>\r\n#include <memory.h>\r\n#include <tchar.h>\r\n\r\n//#include <Ws2tcpip.h>\r\n\r\n#include <CommCtrl.h> \r\n#pragma comment(lib, \"ComCtl32.Lib\") \r\n#pragma comment(linker, \"/manifestdependency:\\\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\\\"\") \r\n\r\n// TODO: ڴ˴óҪĸͷ\r\n"
  }
]