[
  {
    "path": ".gitignore",
    "content": "*.o\nmoc_*.cpp\n*.pro.user*\nui_*.h\nqrc_resources.cpp\nhairless-midiserial\n*~\nMakefile\n*#\n"
  },
  {
    "path": ".gitmodules",
    "content": "[submodule \"rtmidi\"]\n\tpath = libraries/rtmidi\n\turl = https://github.com/thestk/rtmidi.git\n[submodule \"libraries/qextserialport\"]\n\tpath = libraries/qextserialport\n\turl = https://github.com/qextserialport/qextserialport.git\n"
  },
  {
    "path": "LICENSE",
    "content": "Hairless MIDI<->Serial Bridge\n\nOriginal portions Copyright (c) 2011-2014 Angus Gratton\n\nThis library is free software; you can redistribute it and/or\nmodify it under the terms of the GNU Lesser General Public\nLicense as published by the Free Software Foundation; either\nversion 2.1 of the License, or (at your option) any later version.\n\nThis library is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\nLesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public\nLicense along with this library; if not, write to the Free Software\nFoundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\n\n\n***\n\n\"Hairless MIDI<->Serial Bridge\" is a combined work, incorporating the qextserialport and RtMidi libraries.\n\nqextserialport\nCopyright (c) 2009 Michal Policht\nAll rights reserved.\n\nRtMidi: realtime MIDI i/o C++ classes\nCopyright (c) 2003-2014 Gary P. Scavone\n"
  },
  {
    "path": "README.md",
    "content": "Hairless MIDI<->Serial Bridge is the easiest way to connect serial devices (like Arduinos) to send and receive MIDI signals.\n\nThe project home page is http://projectgus.github.com/hairless-midiserial/\n\nPlease see that page for information on running and using Hairless Midiserial, and downloadable compiled versions for Windows, OS X and Linux.\n\n# Building Hairless Bridge from source\n\n(Note again, prebuilt versions *are available for download* at the above URL.)\n\nHairless uses git submodules for library dependencies, so you should use `git clone --recursive URL` when cloning from Github. Alternatively, you can run `git submodule update --init` in order to fetch the submodules to an already-cloned directory.\n\nHairless Midiserial Bridge release 0.4 was built with Qt 4.7.3. It's also been built and run under Qt 4.7.4 & 4.8.6. Newer Qt version 5.0 will probably require code changes in order to compile and/or run.\n\nThe Qt package should contain all dependencies, the graphical IDE \"Qt Creator\" or the program \"qmake\" can be used to compile the project hairless-midiserial.pro.\n\nOn Windows I recommend building with the [MingGW compiler](http://www.mingw.org/), Visual Studio has not been tested. Neither the MinGW site nor Qt's new owners Digia still distribute older MinGW builds, and MinGW 4.7 is too new for precompiled Qt 4.7.x, so it can be a bit hard to find a prebuilt combination that work. Recently I downloaded `mingw-static-4.4.5-all.7z` from [this Google Code project](https://code.google.com/p/qp-gcc/downloads/list), and can confirm that works.\n\n(For the Windows release builds I actually [cross-build under Linux using wine, as described here](http://projectgus.com/2011/09/developing-qt-apps-for-windows-using-linux-wine/).)\n\n# Libraries\n\n* [qextserialport](https://code.google.com/p/qextserialport/) is hosted on Github and is linked into the source tree as a git submodule.\n\n* [The RtMidi library](https://github.com/thestk/rtmidi) is hosted on Github and is linked into the source tree as a git submodule.\n\nBoth libraries are small so they compiled as source files directly into Hairless Bridge, not linked as libraries.\n\n# Release builds\n\nThe official releases are static linked, so they've actually been built against Qt versions that were compiled from source, configured with `-static` for static linking.\n"
  },
  {
    "path": "ardumidi/LICENSE",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <http://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 <http://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<http://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<http://www.gnu.org/philosophy/why-not-lgpl.html>.\n"
  },
  {
    "path": "ardumidi/ardumidi.cpp",
    "content": "/*\n    This file is part of ttymidi.\n\n    ttymidi 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    ttymidi 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 ttymidi.  If not, see <http://www.gnu.org/licenses/>.\n*/\n// file version 0.60\n\n#include \"ardumidi.h\"\n#include \"HardwareSerial.h\"\n\nvoid midi_note_off(byte channel, byte key, byte velocity)\n{\n\tmidi_command(0x80, channel, key, velocity);\n}\n\nvoid midi_note_on(byte channel, byte key, byte velocity)\n{\n\tmidi_command(0x90, channel, key, velocity);\n}\n\nvoid midi_key_pressure(byte channel, byte key, byte value)\n{\n\tmidi_command(0xA0, channel, key, value);\n}\n\nvoid midi_controller_change(byte channel, byte control, byte value)\n{\n\tmidi_command(0xB0, channel, control, value);\n}\n\nvoid midi_program_change(byte channel, byte program)\n{\n\tmidi_command_short(0xC0, channel, program);\n}\n\nvoid midi_channel_pressure(byte channel, byte value)\n{\n\tmidi_command_short(0xD0, channel, value);\n}\n\nvoid midi_pitch_bend(byte channel, int value)\n{\n\tmidi_command(0xE0, channel, value & 0x7F, value >> 7);\n}\n\nvoid midi_command(byte command, byte channel, byte param1, byte param2)\n{\n\tSerial.write(command | (channel & 0x0F));\n\tSerial.write(param1 & 0x7F);\n\tSerial.write(param2 & 0x7F);\n}\n\nvoid midi_command_short(byte command, byte channel, byte param1)\n{\n\tSerial.write(command | (channel & 0x0F));\n\tSerial.write(param1 & 0x7F);\n}\n\nvoid midi_print(char* msg, int len)\n{\n\tSerial.write(0xFF);\n\tSerial.write(0x00);\n\tSerial.write(0x00);\n\tSerial.write(len);\n\tSerial.write(msg);\n}\n\nvoid midi_comment(char* msg)\n{\n\tint   len = 0;\n\tchar* ptr = msg;\n\twhile (*ptr++) len++;\n\tmidi_print(msg, len);\n}\n\nint midi_message_available() {\n\t/* \n\t   This bit will check that next bytes to be read would actually\n\t   have the midi status bit. If not it will remove uncorrect bytes\n\t   from internal buffer \n\t   */\n\twhile ((Serial.available() > 0) && ((Serial.peek() & B10000000) != 0x80)) {\n\t\tSerial.read();\n\t}\n\n\t/* Well we don't exactly know how many commands there might be in the Serial buffer\n           so we'll just guess it according the type of message that happens to be waiting\n           in the buffer. At least we get first one right! */\n\tbyte command = Serial.peek() & 11110000;\n\tif (command != MIDI_PROGRAM_CHANGE && command != MIDI_CHANNEL_PRESSURE) {\n\t\treturn (Serial.available()/2);\n\t}\n\treturn (Serial.available()/3);\n}\n\nMidiMessage read_midi_message() {\n\tMidiMessage message;\n\tbyte midi_status = Serial.read();\n\tmessage.command  = (midi_status & B11110000);\n\tmessage.channel  = (midi_status & B00001111);\n\tmessage.param1   = Serial.read();\n\tif (message.command != MIDI_PROGRAM_CHANGE && message.command != MIDI_CHANNEL_PRESSURE) {\n\t\tmessage.param2   = Serial.read();\n\t}\n\treturn message;\n}\n\nint get_pitch_bend(MidiMessage m) {\n\treturn (m.param1 & 0x7F) + ((m.param2 & 0x7F) << 7);\n}\n\n"
  },
  {
    "path": "ardumidi/ardumidi.h",
    "content": "/*\n    This file is part of ttymidi.\n\n    ttymidi 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    ttymidi 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 ttymidi.  If not, see <http://www.gnu.org/licenses/>.\n*/\n// file version 0.60\n\n#ifndef ardumidi_h\n#define ardumidi_h\n\n#if (ARDUINO >= 100)\n #include <Arduino.h>\n#else\n#include \"WProgram.h\"\n#endif\n\n// MIDI notes\n#define MIDI_C0            0\n#define MIDI_D0            2\n#define MIDI_E0            4\n#define MIDI_F0            5\n#define MIDI_G0            7\n#define MIDI_A0            9\n#define MIDI_B0           11\n#define MIDI_C            60\n#define MIDI_D            62\n#define MIDI_E            64\n#define MIDI_F            65\n#define MIDI_G            67\n#define MIDI_A            69\n#define MIDI_B            71\n#define MIDI_SHARP         1\n#define MIDI_FLAT         -1\n#define MIDI_OCTAVE       12\n\n// MIDI out\n#define MIDI_NOTE_OFF          0x80\n#define MIDI_NOTE_ON           0x90\n#define MIDI_PRESSURE          0xA0\n#define MIDI_CONTROLLER_CHANGE 0xB0\n#define MIDI_PROGRAM_CHANGE    0xC0\n#define MIDI_CHANNEL_PRESSURE  0xD0\n#define MIDI_PITCH_BEND        0xE0\n\nstruct MidiMessage {\n\tbyte command;\n\tbyte channel;\n\tbyte param1;\n\tbyte param2;\n};\n\n// MIDI in\nvoid midi_note_off(byte channel, byte key, byte velocity);\nvoid midi_note_on(byte channel, byte key, byte velocity);\nvoid midi_key_pressure(byte channel, byte key, byte value);\nvoid midi_controller_change(byte channel, byte control, byte value);\nvoid midi_program_change(byte channel, byte program);\nvoid midi_channel_pressure(byte channel, byte value);\nvoid midi_pitch_bend(byte channel, int value);\nvoid midi_command(byte command, byte channel, byte param1, byte param2);\nvoid midi_command_short(byte command, byte channel, byte param1);\n\n// MIDI out\nint midi_message_available();\nMidiMessage read_midi_message();\nint get_pitch_bend(MidiMessage msg);\n\n// Other \nvoid midi_print(char* msg, int len);\nvoid midi_comment(char* msg);\n\n#endif\n"
  },
  {
    "path": "ardumidi/examples/ardumidi_test/ardumidi_test.pde",
    "content": "/*\n  This file is public domain. Use it as you like.\n*/\n\n#include <ardumidi.h>\n\nint ledPin = 13;\nint note_on = 0;\n\nvoid setup()\n{\n  Serial.begin(115200);\n  pinMode(ledPin, OUTPUT);\n}\n\nvoid loop()\n{\n  \n  if (!note_on)\n  {\n\t// play a Cminor chord on channel 0, at maximum volume (127)\n    midi_note_on(0, MIDI_C, 127);\n    midi_note_on(0, MIDI_E + MIDI_FLAT + MIDI_OCTAVE, 127);\n    midi_note_on(0, MIDI_G + MIDI_OCTAVE, 127);\n\n\t// The MIDI_* macros were created to make your life easier, but you\n\t// don't have to use them. You may enter numbers instead if you know\n\t// what you're doing.\n\n    note_on = 1;\n    digitalWrite(ledPin, HIGH);\n  }\n\n  else\n  {\n\t// stop the Cminor chord\n    midi_note_off(0, MIDI_C, 127);\n    midi_note_off(0, MIDI_E + MIDI_FLAT + MIDI_OCTAVE, 127);\n    midi_note_off(0, MIDI_G + MIDI_OCTAVE, 127);\n\n    note_on = 0;\n    digitalWrite(ledPin, LOW);\n  }\n  \n  delay(500);\n}\n\n// Available commands:\n//\n// Start/stop playing a certain note:\n//   midi_note_on(byte channel, byte key, byte velocity);\n//   midi_note_off(byte channel, byte key, byte velocity);\n//\n// Change pressure of specific keys:\n//   midi_key_pressure(byte channel, byte key, byte value);\n//\n// Change controller value (used for knobs, etc):\n//   midi_controller_change(byte channel, byte controller, byte value);\n//\n// Change \"program\" (change the instrument):\n//   midi_program_change(byte channel, byte program);\n//\n// Change key pressure of entire channels:\n//   midi_channel_pressure(byte channel, byte value);\n//\n// Change pitch-bend wheel:\n//   midi_pitch_bend(byte channel, int value);\n//\n// Send a comment:\n//   midi_comment(char* str);\n//\n// Send a series of bytes (to be interpreted by another program):\n//   midi_printbytes(char* bytes, int len);\n//\n// Parameters:\n//   channel             an integer from 0 to 15\n//   pitch-bend value    an integer from 0 to 16383\n//   all other values    an integer from 0 to 127\n//\n\n"
  },
  {
    "path": "ardumidi/examples/ardumidi_test_all_instruments/ardumidi_test_all_instruments.pde",
    "content": "/*\n  This file is public domain. Use it as you like.\n*/\n\n#include <ardumidi.h>\n\nint ledPin = 13;\nint note_on = 0;\nint voice = 0;\n\nvoid setup()\n{\n  Serial.begin(115200);\n  pinMode(ledPin, OUTPUT);\n}\n\nvoid loop()\n{\n  \n  if (!note_on)\n  {\n\t// play a Cminor chord on channel 0, at maximum volume (127)\n    midi_note_on(0, MIDI_C, 127);\n    midi_note_on(0, MIDI_E + MIDI_FLAT + MIDI_OCTAVE, 127);\n    midi_note_on(0, MIDI_G + MIDI_OCTAVE, 127);\n\n\t// The MIDI_* macros were created to make your life easier, but you\n\t// don't have to use them. You may enter numbers instead if you know\n\t// what you're doing.\n\n    note_on = 1;\n    digitalWrite(ledPin, HIGH);\n  }\n\n  else\n  {\n\t// stop the Cminor chord\n    midi_note_off(0, MIDI_C, 127);\n    midi_note_off(0, MIDI_E + MIDI_FLAT + MIDI_OCTAVE, 127);\n    midi_note_off(0, MIDI_G + MIDI_OCTAVE, 127);\n\n    // go to next instrument\n    voice++;\n    if (voice > 255) voice = 0;\n    midi_program_change(0, voice);\n\n    note_on = 0;\n    digitalWrite(ledPin, LOW);\n  }\n  \n  delay(500);\n}\n\n// Available commands:\n//\n// Start/stop playing a certain note:\n//   midi_note_on(byte channel, byte key, byte velocity);\n//   midi_note_off(byte channel, byte key, byte velocity);\n//\n// Change pressure of specific keys:\n//   midi_key_pressure(byte channel, byte key, byte value);\n//\n// Change controller value (used for knobs, etc):\n//   midi_controller_change(byte channel, byte controller, byte value);\n//\n// Change \"program\" (change the instrument):\n//   midi_program_change(byte channel, byte program);\n//\n// Change key pressure of entire channels:\n//   midi_channel_pressure(byte channel, byte value);\n//\n// Change pitch-bend wheel:\n//   midi_pitch_bend(byte channel, int value);\n//\n// Send a comment:\n//   midi_comment(char* str);\n//\n// Send a series of bytes (to be interpreted by another program):\n//   midi_printbytes(char* bytes, int len);\n//\n// Parameters:\n//   channel             an integer from 0 to 15\n//   pitch-bend value    an integer from 0 to 16383\n//   all other values    an integer from 0 to 127\n//\n\n"
  },
  {
    "path": "ardumidi/examples/from_alsa_to_arduino/from_alsa_to_arduino.pde",
    "content": "/*\n  This file is public domain. Use it as you like.\n  \n  This is an example program to showcase reading  with \n  Arduino the MIDI output from an ALSA sequencer. This simply\n  toggles the Arduino LED whenever a MIDI \"note on\" or \"note off\"\n  event takes place.\n*/\n\n#include <ardumidi.h>\n\nvoid setup()\n{\n  Serial.begin(115200);\n  pinMode(ledPin, OUTPUT);\n}\n\nint counter = 0;\n\nvoid loop()\n{\n\twhile (midi_message_available() > 0) {\n\n\t\tMidiMessage m = read_midi_message();\n\n\t\tif (m.command == MIDI_NOTE_ON) {\n\t\t\t/* \n\t\t\tIf you want to find out which key was pressed, check\n\t\t\tthe value of m.param1\n\t\t\t*/\n\t\t\tdigitalWrite(ledPin, HIGH);\n\t    } \n\n\t\telse if (m.command == MIDI_NOTE_OFF) {\n\t\t\tdigitalWrite(ledPin, LOW);\n\t\t}\n\n\t}\n}\n"
  },
  {
    "path": "hairless-midiserial.pro",
    "content": "#-------------------------------------------------\n#\n# Project created by QtCreator 2011-08-08T17:57:42\n#\n#-------------------------------------------------\n\nQT       += core gui\n\nTARGET = hairless-midiserial\nTEMPLATE = app\n\nDEFINES +=APPNAME=\\\"hairless-midiserial\\\"\n\nDEFINES += VERSION=\\\\\\\"0.4\\\\\\\"\n\n# Main Program\n\nSOURCES += \\\n    src/main.cpp \\\n    src/Bridge.cpp \\\n    src/BlinkenLight.cpp \\\n    src/ui/mainwindow.cpp \\\n    src/ui/aboutdialog.cpp \\\n    src/ui/settingsdialog.cpp\n\nHEADERS  += \\\n    src/Bridge.h \\\n    src/Settings.h \\\n    src/BlinkenLight.h \\\n    src/ui/mainwindow.h \\\n    src/ui/settingsdialog.h \\\n    src/ui/aboutdialog.h\n\nFORMS += src/ui/mainwindow.ui \\\n    src/ui/settingsdialog.ui \\\n    src/ui/aboutdialog.ui\n\nINCLUDEPATH += src/\n\n# Universal binary for OS X\n\nmacx {\n    CONFIG += ppc x86\n}\n\n\n# Static flags for windows\n\nwin32 {\n  QMAKE_LFLAGS += -static -static-libgcc\n}\n\n# Icon stuff\n\nwin32 {\n  RC_FILE = \"images/icon.rc\"\n}\nmacx {\n  ICON = \"images/icon.icns\"\n}\n# linux has no baked-in icon support, but we load a resource to use as a window icon\n\n# qextserialport\n\nHEADERS                 += libraries/qextserialport/src/qextserialport.h \\\n                          libraries/qextserialport/src/qextserialenumerator.h \\\n                          libraries/qextserialport/src/qextserialport_global.h\nSOURCES                 += libraries/qextserialport/src/qextserialport.cpp \\\n                           libraries/qextserialport/src/qextserialenumerator.cpp\n\nunix:SOURCES           += libraries/qextserialport/src/qextserialport_unix.cpp\nunix:!macx:SOURCES     += libraries/qextserialport/src/qextserialenumerator_linux.cpp\nunix:!macx:LIBS        += -ludev\n\nmacx {\n  SOURCES          += libraries/qextserialport/src/qextserialenumerator_osx.cpp\n  LIBS             += -framework IOKit -framework CoreFoundation\n}\n\nwin32 {\n  SOURCES          += libraries/qextserialport/src/win_qextserialport.cpp \\\n                      libraries/qextserialport/src/qextserialenumerator_win.cpp\n  DEFINES          += WINVER=0x0501 # needed for mingw to pull in appropriate dbt business...probably a better way to do this\n  LIBS             += -lsetupapi\n}\n\nINCLUDEPATH += libraries/qextserialport/src/\n\n# RtMidi\n\nHEADERS +=    libraries/rtmidi/RtMidi.h \\\n              src/QRtMidiIn.h \\\n\nSOURCES +=    libraries/rtmidi/RtMidi.cpp \\\n              src/QRtMidiIn.cpp\n\nINCLUDEPATH += libraries/rtmidi/\n\nlinux-* { # linux doesn't get picked up, not sure what else to use\n  DEFINES += __LINUX_ALSASEQ__\n  CONFIG += link_pkgconfig x11\n  PKGCONFIG += alsa\n  LIBS += -lpthread\n}\nwin32 {\n  DEFINES += __WINDOWS_MM__\n  LIBS += -lwinmm\n}\nmacx {\n    DEFINES += __MACOSX_CORE__\n    LIBS += -framework \\\n        CoreMidi \\\n        -framework \\\n        CoreAudio \\\n        -framework \\\n        CoreFoundation\n}\n\n# PortLatency\nSOURCES += src/PortLatency.cpp\nHEADERS += src/PortLatency.h\nlinux-* {\n   SOURCES += src/PortLatency_linux.cpp\n}\nwin32 {\n   SOURCES += src/PortLatency_win32.cpp\n}\nmacx {\n   SOURCES += src/PortLatency_osx.cpp\n}\n\n# Resources\n\nRESOURCES += \\\n    resources.qrc\n"
  },
  {
    "path": "images/icon.rc",
    "content": "IDI_ICON1               ICON    DISCARDABLE     \"icon.ico\"\n"
  },
  {
    "path": "resources.qrc",
    "content": "<RCC>\n    <qresource prefix=\"/images\">\n        <file>images/arrows.png</file>\n        <file>images/led-off.png</file>\n        <file>images/led-on.png</file>\n        <file>images/logo.png</file>\n        <file>images/icon48.png</file>\n    </qresource>\n</RCC>\n"
  },
  {
    "path": "src/BlinkenLight.cpp",
    "content": "#include \"BlinkenLight.h\"\n#include <QPixmapCache>\n\nconst int DEFAULT_LED_BLINKTIME= 75; // ms\n\nconst QString RES_LED_ON = \":/images/images/led-on.png\";\nconst QString RES_LED_OFF = \":/images/images/led-off.png\";\n\nBlinkenLight::BlinkenLight(QWidget *parent) :\n    QLabel(parent),\n    on(false),\n    timer()\n{\n    timer.setSingleShot(true);\n    timer.setInterval(DEFAULT_LED_BLINKTIME);\n    connect(&timer, SIGNAL(timeout()), this, SLOT(blinkOff()));\n}\n\nstatic QPixmap getCachedPixmap(const QString name)\n{\n    QPixmap res;\n    if(!QPixmapCache::find(name, &res)) {\n        res = QPixmap::fromImage(QImage(name));\n        QPixmapCache::insert(name, res);\n    }\n    return res;\n}\n\nvoid BlinkenLight::blinkOn()\n{\n    if(on) return;\n    timer.start();\n    this->setPixmap(getCachedPixmap(RES_LED_ON));\n    on = true;\n}\n\nvoid BlinkenLight::blinkOff()\n{\n    if(!on) return;\n    this->setPixmap(getCachedPixmap(RES_LED_OFF));\n    on = false;\n}\n"
  },
  {
    "path": "src/BlinkenLight.h",
    "content": "#ifndef BLINKENLIGHT_H\n#define BLINKENLIGHT_H\n\n#include <QObject>\n#include <QLabel>\n#include <QTimer>\n\n/*\n * A custom QLabel that looks like a blinking LED.\n * Handles blinking off after a specified time, all by itself.\n */\nclass BlinkenLight : public QLabel\n{\n    Q_OBJECT\npublic:\n    explicit BlinkenLight(QWidget *parent = 0);\n    void setBlinkTime(int blinkTime) { this->timer.setInterval(blinkTime); }\n    ~BlinkenLight() { }\nprivate:\n    bool on;\n    QTimer timer;\npublic slots:\n    void blinkOn();\nprivate slots:\n    void blinkOff();\n};\n\n#endif // BLINKENLIGHT_H\n"
  },
  {
    "path": "src/Bridge.cpp",
    "content": "#include \"Bridge.h\"\n#include \"qextserialenumerator.h\"\n#include <QList>\n#include <QVector>\n#include <QIODevice>\n#include <stdint.h>\n#include \"PortLatency.h\"\n\n// MIDI message masks\nconst uint8_t STATUS_MASK = 0x80;\nconst uint8_t CHANNEL_MASK = 0x0F;\nconst uint8_t  TAG_MASK = 0xF0;\n\nconst uint8_t TAG_NOTE_OFF = 0x80;\nconst uint8_t TAG_NOTE_ON = 0x90;\nconst uint8_t TAG_KEY_PRESSURE = 0xA0;\nconst uint8_t TAG_CONTROLLER = 0xB0;\nconst uint8_t TAG_PROGRAM = 0xC0;\nconst uint8_t TAG_CHANNEL_PRESSURE = 0xD0;\nconst uint8_t TAG_PITCH_BEND = 0xE0;\nconst uint8_t TAG_SPECIAL = 0xF0;\n\nconst uint8_t MSG_SYSEX_START = 0xF0;\nconst uint8_t MSG_SYSEX_END = 0xF7;\n\nconst uint8_t MSG_DEBUG = 0xFF; // special ttymidi \"debug output\" MIDI message tag\n\ninline bool is_voice_msg(uint8_t tag) { return tag >= 0x80 && tag <= 0xEF; };\ninline bool is_syscommon_msg(uint8_t tag) { return tag >= 0xF0 && tag <= 0xF7; };\ninline bool is_realtime_msg(uint8_t tag) { return tag >= 0xF8 && tag < 0xFF; };\n\n\n// return the number of data bytes for a given message status byte\n#define UNKNOWN_MIDI -2\nstatic int get_data_length(int status) {\n    uint8_t channel;\n    switch(status & TAG_MASK) {\n    case TAG_PROGRAM:\n    case TAG_CHANNEL_PRESSURE:\n      return 1;\n    case TAG_NOTE_ON:\n    case TAG_NOTE_OFF:\n    case TAG_KEY_PRESSURE:\n    case TAG_CONTROLLER:\n    case TAG_PITCH_BEND:\n      return 2;\n    case TAG_SPECIAL:\n      if(status == MSG_DEBUG) {\n        return 3; // Debug messages go { 0xFF, 0, 0, <len>, Msg } so first we read 3 data bytes to get full length\n      }\n      if(status == MSG_SYSEX_START) {\n        return 65535; // SysEx messages go until we see a SysExEnd\n      }\n      channel = status & CHANNEL_MASK;\n      if(channel < 3) {\n        return 2;\n      } else if (channel < 6) {\n        return 1;\n      }\n      return 0;\n    default:\n      // Unknown midi message...?\n      return UNKNOWN_MIDI;\n    }\n}\n\n\nBridge::Bridge() :\n        QObject(),      \n        running_status(0),\n        data_expected(0),\n        msg_data(),\n        midiIn(NULL),\n        midiOut(NULL),\n        serial(NULL),\n        latency(NULL),\n        attachTime(QTime::currentTime())\n{\n}\n\nvoid Bridge::attach(QString serialName, PortSettings serialSettings, int midiInPort, int midiOutPort, QThread *workerThread)\n{\n    this->moveToThread(workerThread);\n    if(serialName.length() && serialName != TEXT_NOT_CONNECTED) {\n        // Latency fixups\n        latency = new PortLatency(serialName);\n        connect(latency, SIGNAL(debugMessage(QString)), this, SIGNAL(debugMessage(QString)));\n        connect(latency, SIGNAL(errorMessage(QString)), this, SIGNAL(displayMessage(QString)));\n        latency->fixLatency();\n\n        emit displayMessage(QString(\"Opening serial port '%1'...\").arg(serialName));\n        this->serial = new QextSerialPort(serialName, serialSettings);\n        connect(this->serial, SIGNAL(readyRead()), this, SLOT(onSerialAvailable()));\n        this->serial->open(QIODevice::ReadWrite|QIODevice::Unbuffered);\n        attachTime = QTime::currentTime();\n        this->serial->moveToThread(workerThread);\n    }\n\n    // MIDI out\n    try\n    {\n        if(midiOutPort > -1)\n        {\n            emit displayMessage(QString(\"Opening MIDI Out port #%1\").arg(midiOutPort));\n            this->midiOutPort = midiOutPort;\n            this->midiOut = new RtMidiOut(RtMidi::UNSPECIFIED, NAME_MIDI_OUT);\n            this->midiOut->openPort(midiOutPort);\n        }\n    }\n    catch(RtMidiError e)\n    {\n        displayMessage(QString(\"Failed to open MIDI out port: %1\").arg(QString::fromStdString(e.getMessage())));\n    }\n\n    // MIDI in\n    try\n    {\n       if(midiInPort > -1) {\n            emit displayMessage(QString(\"Opening MIDI In port #%1\").arg(midiInPort));\n            this->midiInPort = midiInPort;\n            this->midiIn = new QRtMidiIn(NAME_MIDI_IN);\n            this->midiIn->moveToThread(workerThread);\n            this->midiIn->openPort(midiInPort);\n            connect(this->midiIn, SIGNAL(messageReceived(double,QByteArray)), this, SLOT(onMidiIn(double,QByteArray)));\n        }\n     }\n    catch(RtMidiError e)\n    {\n        displayMessage(QString(\"Failed to open MIDI in port: %1\").arg(QString::fromStdString(e.getMessage())));\n    }\n}\n\nBridge::~Bridge()\n{\n    emit displayMessage(applyTimeStamp(\"Closing MIDI<->Serial bridge...\"));\n    if(this->latency) {\n        this->latency->resetLatency();\n    }\n    delete this->midiIn;\n    delete this->midiOut;\n    delete this->serial;\n}\n\nvoid Bridge::onMidiIn(double timeStamp, QByteArray message)\n{\n    QString description = describeMIDI(message);\n    emit debugMessage(applyTimeStamp(QString(\"MIDI In: %1\").arg(description)));\n    emit midiReceived();\n    if(serial && serial->isOpen()) {\n        serial->write(message);\n        emit serialTraffic();\n    }\n}\n\nvoid Bridge::onSerialAvailable()\n{\n    emit serialTraffic();\n    QByteArray data = this->serial->readAll();\n    foreach(uint8_t next, data) {\n      if (next & STATUS_MASK)\n        this->onStatusByte(next);\n      else\n        this->onDataByte(next);\n      if(this->data_expected == 0)\n        sendMidiMessage();\n    }\n}\n\nvoid Bridge::onStatusByte(uint8_t byte) {\n  if(byte == MSG_SYSEX_END && bufferStartsWith(MSG_SYSEX_START)) {\n    this->msg_data.append(byte); // bookends of a complete SysEx message\n    sendMidiMessage();\n    return;\n  }\n\n  if(this->data_expected > 0) {\n    emit displayMessage(applyTimeStamp(QString(\"Warning: got a status byte when we were expecting %1 more data bytes, sending possibly incomplete MIDI message 0x%2\").arg(this->data_expected).arg((uint8_t)this->msg_data[0], 0, 16)));\n    sendMidiMessage();\n  }\n\n  if(is_voice_msg(byte))\n    this->running_status = byte;\n  if(is_syscommon_msg(byte))\n    this->running_status = 0;\n\n  this->data_expected = get_data_length(byte);\n  if(this->data_expected == UNKNOWN_MIDI) {\n      emit displayMessage(applyTimeStamp(QString(\"Warning: got unexpected status byte %1\").arg((uint8_t)byte,0,16)));\n      this->data_expected = 0;\n  }\n  this->msg_data.clear();\n  this->msg_data.append(byte);\n}\n\nvoid Bridge::onDataByte(uint8_t byte)\n{\n  if(this->data_expected == 0 && this->running_status != 0) {\n    onStatusByte(this->running_status);\n  }\n  if(this->data_expected == 0) { // checking again just in in case running status failed to update us to expect data\n    emit displayMessage(applyTimeStamp(QString(\"Error: got unexpected data byte 0x%1.\").arg((uint8_t)byte,0,16)));\n    return;\n  }\n\n  this->msg_data.append(byte);\n  this->data_expected--;\n\n  if( bufferStartsWith(MSG_DEBUG)\n      && this->data_expected == 0\n      && this->msg_data.length() == 4) { // we've read the length of the debug message\n    this->data_expected += this->msg_data[3]; // add the message length\n  }\n}\n\nvoid Bridge::sendMidiMessage() {\n  if(msg_data.length() == 0)\n    return;\n  if(bufferStartsWith(MSG_DEBUG)) {\n      QString debug_msg = QString::fromAscii(msg_data.mid(4, msg_data[3]).data());\n      emit displayMessage(applyTimeStamp(QString(\"Serial Says: %1\").arg(debug_msg)));\n  } else {\n      emit debugMessage(applyTimeStamp(QString(\"Serial In: %1\").arg(describeMIDI(msg_data))));\n      if(midiOut) {\n        std::vector<uint8_t> message = std::vector<uint8_t>(msg_data.begin(), msg_data.end());\n        midiOut->sendMessage(&message);\n        emit midiSent();\n      }\n  }\n  msg_data.clear();\n  data_expected = 0;\n}\n\n/*\n * Given a buffer containing what is hopefully a MIDI message,\n * return a string describing the MIDI message.\n */\nQString Bridge::describeMIDI(QByteArray &buf)\n{\n    uint8_t msg = buf[0];\n    uint8_t tag = msg & TAG_MASK;\n    uint8_t channel = msg & CHANNEL_MASK;\n    const char *desc= 0;\n\n    // Work out what we have\n\n    switch(tag) {\n    case TAG_PROGRAM:\n        desc = \"Ch %1: Program change %2\";\n        break;\n    case TAG_CHANNEL_PRESSURE:\n        desc = \"Ch %1: Pressure change %2\";\n        break;\n    case TAG_NOTE_ON:\n        desc = \"Ch %1: Note %2 on  velocity %3\";\n        break;\n    case TAG_NOTE_OFF:\n        desc = \"Ch %1: Note %2 off velocity %3\";\n        break;\n    case TAG_KEY_PRESSURE:\n        desc = \"Ch %1: Note %2 pressure %3\";\n        break;\n    case TAG_CONTROLLER:\n        desc = \"Ch %1: Controller %2 value %3\";\n        break;\n    case TAG_PITCH_BEND:\n        desc = \"Ch %1: Pitch bend %2\";\n        break;\n    case TAG_SPECIAL:\n        if(msg == MSG_SYSEX_START) {\n            QString res = \"SysEx Message: \";\n            for(int i = 1; i < buf.length(); i++) {\n                uint8_t val = buf[i];\n                if(val == MSG_SYSEX_END)\n                    break;\n                res.append(QString(\"0x%1 \").arg(val,0,16));\n            }\n            return res;\n        }\n        if(channel < 3) {\n            desc = \"System Message #%1: %2 %3\";\n        } else if (channel < 6) {\n            desc = \"System Message #%1: %2\";\n        } else {\n            desc = \"System Message #%1\";\n        }\n        break;\n    default:\n        return QString(\"Unknown MIDI message %1\").arg(QString(buf.toHex()));\n    }\n\n    // Format the output\n\n    QString qdesc = QString(desc).arg((int) channel+(tag==TAG_SPECIAL?0:1));\n\n    if(tag == TAG_PITCH_BEND && buf.length() == 3) { // recombine LSB/MSB for pitch bend\n        return qdesc.arg((int) ((uint8_t)buf[1]) | ((uint8_t) buf[2])<<7 );\n    }\n\n    int i = 1;\n    while(qdesc.contains(\"%\") && i < buf.length()) {\n      qdesc = qdesc.arg((int) buf[i++]);\n    }\n    return qdesc;\n}\n\nQString Bridge::applyTimeStamp(QString message)\n{\n    QTime now = QTime::currentTime();\n    float msecs = this->attachTime.msecsTo(now) / 1000.0;\n    return QString(\"+%1 - %2\").arg(msecs, 4).arg(message);\n}\n\n"
  },
  {
    "path": "src/Bridge.h",
    "content": "#ifndef BRIDGE_H\n#define BRIDGE_H\n\n/*\n * Bridge is the actual controller that bridges Serial <-> MIDI. Create it by passing the\n * the serial & MIDI ports to use (or NULL if that part is not used.)\n *\n * The Bridge manages its own internal state, and can be deleted when you stop bridging and/or\n * recreated with new settings.\n */\n\n#include <QObject>\n#include <QTime>\n#include <QThread>\n#include \"RtMidi.h\"\n#include \"QRtMidiIn.h\"\n#include \"qextserialport.h\"\n#include \"PortLatency.h\"\n\nconst QString TEXT_NOT_CONNECTED = \"(Not Connected)\";\nconst QString TEXT_NEW_PORT = \"(Create new port)\";\n\n#define NAME_MIDI_IN \"MIDI->Serial\"\n#define NAME_MIDI_OUT \"Serial->MIDI\"\n\nclass Bridge : public QObject\n{\n    Q_OBJECT\npublic:\n    explicit Bridge();\n    void attach(QString serialName, PortSettings serialSettings, int midiInPort, int midiOutPort, QThread *workerThread);\n\n    // Destroying an existing Bridge will cleanup state & release all ports\n    ~Bridge();\n\nsignals:\n    // Signals to push user status messages\n    void displayMessage(QString message);\n    void debugMessage(QString message);\n\n    // Signals to trigger UI \"blinkenlight\" updates\n    void midiReceived();\n    void midiSent();\n    void serialTraffic();\nprivate slots:\n    void onMidiIn(double timeStamp, QByteArray message);\n    void onSerialAvailable();\nprivate:\n    void sendMidiMessage();\n\n    void onDataByte(uint8_t byte);\n    void onStatusByte(uint8_t byte);\n\n    QString applyTimeStamp(QString message);\n    QString describeMIDI(QByteArray &buf);\n\n    bool bufferStartsWith(uint8_t byte) { return this->msg_data.length() && (uint8_t)msg_data[0] == byte; }\n\n    int running_status;       // if we have a running or current status byte, what is it?\n    int data_expected;        // how many bytes of data are we currently waiting on?\n    QByteArray msg_data;      // accumulated message data from the serial port\n    QRtMidiIn *midiIn;\n    RtMidiOut *midiOut;\n    int midiInPort;\n    int midiOutPort;\n    QextSerialPort *serial;\n    PortLatency *latency;\n    QTime attachTime;\n\n\n};\n\n#endif // BRIDGE_H\n"
  },
  {
    "path": "src/PortLatency.cpp",
    "content": "#include \"PortLatency.h\"\n\nPortLatency::PortLatency(QString portName)\n    : portName(portName),\n    isSwitched(false)\n{\n\n}\n"
  },
  {
    "path": "src/PortLatency.h",
    "content": "#ifndef FIXLATENCY_H\n#define FIXLATENCY_H\n\n#include <QObject>\n#include <QString>\n#ifdef Q_OS_WIN32\nextern \"C\" {\n#include <windows.h>\n}\n#endif\n\n/*\n * A simple class to manage latency reduction of FTDI-based serial ports. Implementation varies from\n * OS to OS. Implementation has to determine if port referred to by \"portName\" actually is\n * an FTDI device or not.\n *\n * Emits debug or status messages to indicate its current status\n *\n */\nclass PortLatency : public QObject {\n    Q_OBJECT\npublic:\n    PortLatency(QString portName);\n\n    void fixLatency();\n    void resetLatency();\n\nsignals:\n    void debugMessage(QString message);\n    void errorMessage(QString message);\nprivate:\n    QString portName;\n    bool isSwitched;\n\n#ifdef Q_OS_WIN32\n    bool switchLatency(HKEY paramKey, const wchar_t *readFromKey, const wchar_t *writeToKey, bool checkValue);\n    HKEY openFTDIDeviceParameters();\n#endif\n#ifdef Q_OS_LINUX\n    bool swapAsync(bool setAsyncMode);\n#endif\n};\n\n#endif // FIXLATENCY_H\n"
  },
  {
    "path": "src/PortLatency_linux.cpp",
    "content": "/*\n * Linux implementation of fixing latency on a serial port.\n *\n * qextserialport doesn't provide an easy way to get the USB details from the serial port, to find FTDIs.\n *\n * However, Linux has a much better serial flag called ASYNC_LOW_LATENCY that will do the job, anyhow.\n * ... and maybe work on other serial port types!\n */\n\n#include \"PortLatency.h\"\n\nextern \"C\" {\n#include <sys/ioctl.h>\n#include <linux/serial.h>\n#include <linux/ioctl.h>\n#include <asm/ioctls.h>\n#include <stdio.h>\n#include <fcntl.h>\n#include <unistd.h>\n}\n\nvoid PortLatency::fixLatency()\n{\n    if(swapAsync(true)) {\n        emit debugMessage(QString(\"Switched serial port %1 to low-latency mode\").arg(portName));\n        this->isSwitched = true;\n    }\n}\n\nvoid PortLatency::resetLatency()\n{\n    if(swapAsync(false)) {\n        emit debugMessage(QString(\"Set serial port %1 back to normal mode\").arg(portName));\n        this->isSwitched = false;\n    }\n}\n\nbool PortLatency::swapAsync(bool setAsyncMode)\n{\n    if(isSwitched == setAsyncMode) {\n        return true;\n    }\n    if(!portName.startsWith(\"/dev/\")) {\n        portName.prepend(\"/dev/\");\n    }\n    int fd = open(portName.toAscii().data(), O_NONBLOCK);\n    if(fd <= 0) {\n        emit errorMessage(QString(\"Failed to open serial port device %1 to lower latency\").arg(portName));\n        return false;\n    }\n    struct serial_struct ser_info;\n    int r = ioctl(fd, TIOCGSERIAL, &ser_info);\n    if(r) {\n        emit errorMessage(QString(\"Failed to get serial port info for %1, cannot set low latency mode\").arg(portName));\n        close(fd);\n        return false;\n    }\n    if((ser_info.flags & ASYNC_LOW_LATENCY) == setAsyncMode) {\n        emit debugMessage(QString(\"Serial port %1 already%2 in low latency mode\")\n                          .arg(portName).arg(setAsyncMode ? \"\" : \" not\"));\n        close(fd);\n        return false;\n    }\n    if(setAsyncMode) {\n        ser_info.flags |= ASYNC_LOW_LATENCY;\n    } else {\n        ser_info.flags &= ~ASYNC_LOW_LATENCY;\n    }\n    r = ioctl(fd, TIOCSSERIAL, &ser_info);\n    if(r) {\n        emit errorMessage(QString(\"Failed to set low-latency mode on %1\").arg(portName));\n        close(fd);\n        return false;\n    }\n    close(fd);\n    return true;\n}\n"
  },
  {
    "path": "src/PortLatency_osx.cpp",
    "content": "/*\n * Arduino devices' FTDI chips have a LatencyTimer setting of 2ms by default on OS X\n *\n * So there is not much point doing anything at all here.\n *\n * It would be possible to edit the plist file to reduce latency on other devices,\n * but this is a fairly convoluted process (need to scan file ,elevate privileges -\n * including prompt, then write changes) but it seems like overkill when common devices\n * already work.\n */\n#include \"PortLatency.h\"\n\nvoid PortLatency::fixLatency()\n{\n}\nvoid PortLatency::resetLatency()\n{\n}\n"
  },
  {
    "path": "src/PortLatency_win32.cpp",
    "content": "/*\r\n * Windows implementation of fixing latency on an FTDI-based serial port, using registry.\r\n *\r\n */\r\n\r\n#include \"PortLatency.h\"\r\n#include \"qextserialenumerator.h\"\r\nextern \"C\" {\r\n#include <windows.h>\r\n}\r\n\r\n// Return the windows registry entry for the FTDI device (open), or 0\r\nHKEY PortLatency::openFTDIDeviceParameters()\r\n{\r\n    HKEY key;\r\n    const wchar_t *keypath = L\"SYSTEM\\\\CurrentControlSet\\\\Enum\\\\FTDIBUS\";\r\n    long r = RegOpenKeyEx(HKEY_LOCAL_MACHINE, keypath,\r\n                            0, KEY_READ, &key);\r\n    if(r) {\r\n        emit debugMessage(\"FTDI drivers don't seem to be installed. Not attempting any FTDI latency tricks.\");\r\n        return 0;\r\n    }\r\n\r\n    // Look through available FTDI devices\r\n    int index = 0;\r\n    HKEY readOnlyKey = 0, paramKey = 0;\r\n    while(1) {\r\n        if(paramKey) {\r\n          RegCloseKey(paramKey);\r\n          paramKey = 0;\r\n        }\r\n        DWORD subkey_sz = 140;\r\n        wchar_t subkey[subkey_sz];\r\n        r = RegEnumKeyEx(key, index++, subkey, &subkey_sz, 0, NULL, NULL, NULL);        \r\n        if(r) {\r\n            if(r==ERROR_NO_MORE_ITEMS)\r\n                emit debugMessage(QString(\"Port %1 doesn't seem to be an FTDI device. No latency tricks will be attempted.\").arg(portName));\r\n            else\r\n                emit errorMessage(QString(\"Unexpected error while enumerating FTDI devices.\"));\r\n            break;\r\n        }\r\n        QString paramPath = QString(\"%1\\\\0000\\\\Device Parameters\").arg(QString::fromWCharArray(subkey));\r\n        r = RegOpenKeyEx(key, paramPath.toStdWString().c_str(), 0, KEY_READ, &readOnlyKey);\r\n        if(r) {\r\n            continue;\r\n        }\r\n        DWORD regPortName_sz = 10;\r\n        wchar_t regPortName[regPortName_sz];\r\n        DWORD type;\r\n        r = RegQueryValueEx(readOnlyKey, L\"PortName\", NULL, &type, (LPBYTE)&regPortName, &regPortName_sz);\r\n        if(!r && portName == QString::fromWCharArray(regPortName)) {\r\n           r = RegOpenKeyEx(readOnlyKey, NULL, 0, KEY_READ|KEY_SET_VALUE, &paramKey);\r\n           if(r) {\r\n               emit errorMessage(\"Port is an FTDI device, but we don't have administrator access to change the latency setting.\");\r\n           }\r\n        }\r\n        RegCloseKey(readOnlyKey);\r\n        if(paramKey) break;\r\n    }\r\n    RegCloseKey(key);\r\n    return paramKey;\r\n}\r\n\r\n/*\r\n * Read a DWORD value from one registry value under paramKey and copy it to another value under paramKey\r\n */\r\nbool PortLatency::switchLatency(HKEY paramKey, const wchar_t *readFromKey, const wchar_t *writeToKey, bool checkValue)\r\n{\r\n    DWORD latency, type, lsize = sizeof(DWORD);\r\n    int r = RegQueryValueEx(paramKey, readFromKey, NULL, &type, (LPBYTE)&latency, &lsize);\r\n    if(r) {\r\n        emit errorMessage(QString(\"Failed to read the %1 value for FTDI device %2\").arg(QString::fromWCharArray(readFromKey)).arg(portName));\r\n        return false;\r\n    }\r\n    if(type != REG_DWORD) {\r\n        emit errorMessage(QString(\"%1 of %2 has unexpected type %3\").arg(QString::fromWCharArray(readFromKey)).arg(portName).arg(type));\r\n        return false;\r\n    }\r\n    if(checkValue && latency == 1) {\r\n        emit debugMessage(QString(\"LatencyTimer for %1 has already been turned down to %2\").arg(portName).arg(latency));\r\n        return false;\r\n    }\r\n    r = RegSetValueEx(paramKey, writeToKey, 0, REG_DWORD, (LPBYTE)&latency, sizeof(latency));\r\n    if(r) {\r\n        emit errorMessage(QString(\"Failed to write key %1. Missing privileges?\").arg(QString::fromWCharArray(writeToKey)));\r\n        return false;\r\n    }\r\n    return true;\r\n}\r\n\r\nvoid PortLatency::fixLatency()\r\n{\r\n    if(isSwitched) return;\r\n    HKEY paramKey = openFTDIDeviceParameters();\r\n    if(!paramKey) return;\r\n\r\n    // if we get here, paramKey is the subkey with Device Parameters for our port\r\n\r\n    if(switchLatency(paramKey, L\"LatencyTimer\", L\"OldLatencyTimer\", true))\r\n    {\r\n        DWORD latency = 1;\r\n        int r = RegSetValueEx(paramKey, L\"LatencyTimer\", 0, REG_DWORD, (LPBYTE)&latency, sizeof(latency));\r\n        isSwitched = (r == 0);\r\n    }\r\n    RegCloseKey(paramKey);\r\n}\r\n\r\nvoid PortLatency::resetLatency()\r\n{\r\n    if(!isSwitched) return;\r\n    HKEY paramKey = openFTDIDeviceParameters();\r\n    if(!paramKey) return;\r\n\r\n    // if we get here, paramKey is the subkey with Device Parameters for our port\r\n\r\n    isSwitched = !switchLatency(paramKey, L\"OldLatencyTimer\", L\"LatencyTimer\", false);\r\n    if(!isSwitched)\r\n    {\r\n        int r = RegDeleteValue(paramKey, L\"OldLatencyTimer\");\r\n        if(r) {\r\n            emit debugMessage(\"Failed to delete OldLatencyTimer key after switching back. You can probably ignore this message.\");\r\n        }\r\n    }\r\n    RegCloseKey(paramKey);\r\n}\r\n"
  },
  {
    "path": "src/QRtMidiIn.cpp",
    "content": "#include \"QRtMidiIn.h\"\n\nstatic void midiCallbackOuter(double timeStamp, std::vector<unsigned char> *message, void *userData)\n{\n    QRtMidiIn *midi =(QRtMidiIn *)userData;\n    midi->midiCallback(timeStamp, message);\n}\n\nQRtMidiIn::QRtMidiIn(const std::string clientName) :\n            QObject(0),\n            RtMidiIn(RtMidi::UNSPECIFIED, clientName)\n{\n    this->ignoreTypes(false,false,false); // we want MIDI SysEx, time & sense messages\n    this->setCallback(midiCallbackOuter, this);\n}\n\nvoid QRtMidiIn::midiCallback(double timeStamp, std::vector<unsigned char> *message)\n{\n    QByteArray messageCopy = QByteArray((const char *)message->data(), message->size());\n    emit messageReceived(timeStamp, messageCopy);\n}\n\n"
  },
  {
    "path": "src/QRtMidiIn.h",
    "content": "#ifndef QRTMIDIIN_H\n#define QRTMIDIIN_H\n\n/*\n * Very thin QT wrapper for the cross-platform RtMidiIn class.\n *\n * Exposes the \"new MIDI message\" callback as a QT signal, which can be sent to a QT slot.\n */\n#include \"RtMidi.h\"\n#include <QObject>\n#include <QByteArray>\n#include <stdint.h>\n\nclass QRtMidiIn : public QObject, public RtMidiIn {\n    Q_OBJECT\n\npublic:\n    QRtMidiIn(const std::string clientName = std::string( \"QRtMidi Input Client\") );\n    void midiCallback(double timeStamp, std::vector<unsigned char> *message);\n    virtual ~QRtMidiIn ( void ) throw() { }\nsignals:\n    void messageReceived(double timeStamp, QByteArray message);\n};\n\n#endif // QRTMIDIIN_H\n"
  },
  {
    "path": "src/Settings.h",
    "content": "#ifndef SETTINGS_H\n#define SETTINGS_H\n\n#include <QSettings>\n#include \"qextserialport.h\"\n\n// Note that main.cpp sets QCoreApplication::applicationName and such, allowing us to use a\n// plain QSettings() constructor\n\nclass Settings {\npublic:\n    static QString getLastSerialPort() { return QSettings().value(\"lastSerialPort\", \"\").toString(); }\n    static void setLastSerialPort(QString port) { QSettings().setValue(\"lastSerialPort\", port); }\n\n    static QString getLastMidiIn() { return QSettings().value(\"lastMidiIn\", \"\").toString(); }\n    static void setLastMidiIn(QString port) { QSettings().setValue(\"lastMidiIn\", port); }\n\n    static QString getLastMidiOut() { return QSettings().value(\"lastMidiOut\", \"\").toString(); }\n    static void setLastMidiOut(QString port) { QSettings().setValue(\"lastMidiOut\", port); }\n\n    static int getScrollbackSize() { return QSettings().value(\"scrollbackSize\", 75).toInt(); }\n    static void setScrollbackSize(int newSize) { QSettings().setValue(\"scrollbackSize\", newSize); }\n\n    static bool getDebug() { return QSettings().value(\"debug\", false).toBool(); }\n    static void setDebug(bool debug) { QSettings().setValue(\"debug\", debug); }\n\n    static PortSettings getPortSettings() {\n        PortSettings result;\n        QSettings settings;\n        result.BaudRate = (BaudRateType) settings.value(\"baudRate\", (int)BAUD115200).toInt();\n        result.DataBits = (DataBitsType) settings.value(\"dataBits\", (int)DATA_8).toInt();\n        result.FlowControl = (FlowType)  settings.value(\"flowControl\", (int)FLOW_OFF).toInt();\n        result.Parity = (ParityType) settings.value(\"parity\", (int)PAR_NONE).toInt();\n        result.StopBits = (StopBitsType) settings.value(\"stopBits\", (int)STOP_1).toInt();\n        result.Timeout_Millisec = 1; // not used when qextserialport is event-driven, anyhow\n        return result;\n    }\n\n    static void setPortSettings(PortSettings newSettings) {\n        QSettings settings;\n        settings.setValue(\"baudRate\", (int)newSettings.BaudRate);\n        settings.setValue(\"dataBits\", (int)newSettings.DataBits);\n        settings.setValue(\"flowControl\", (int)newSettings.FlowControl);\n        settings.setValue(\"parity\", (int)newSettings.Parity);\n        settings.setValue(\"stopBits\", (int)newSettings.StopBits);\n    }\n\n};\n\n\n#endif // SETTINGS_H\n"
  },
  {
    "path": "src/main.cpp",
    "content": "#include <QtGui/QApplication>\n#include \"ui/mainwindow.h\"\n\nint main(int argc, char *argv[])\n{\n    QApplication a(argc, argv);\n    QCoreApplication::setOrganizationName(\"Projectgus\");\n    QCoreApplication::setOrganizationDomain(\"projectgus.com\");\n    QCoreApplication::setApplicationName(\"Hairless MIDI Serial Bridge\");\n    MainWindow w;\n    w.show();\n    return a.exec();\n}\n"
  },
  {
    "path": "src/ui/aboutdialog.cpp",
    "content": "#include \"aboutdialog.h\"\n#include \"ui_aboutdialog.h\"\n\nAboutDialog::AboutDialog(QWidget *parent) :\n    QDialog(parent),\n    ui(new Ui::About)\n{\n    ui->setupUi(this);\n\n    QString text = ui->label_info->text().arg(QString::fromAscii(VERSION)).arg(QString::fromAscii(__DATE__));\n    ui->label_info->setText(text);\n}\n\nAboutDialog::~AboutDialog()\n{\n    delete ui;\n}\n"
  },
  {
    "path": "src/ui/aboutdialog.h",
    "content": "#ifndef ABOUTDIALOG_H\n#define ABOUTDIALOG_H\n\n#include <QDialog>\n\nnamespace Ui {\n    class About;\n}\n\nclass AboutDialog : public QDialog\n{\n    Q_OBJECT\n\npublic:\n    explicit AboutDialog(QWidget *parent = 0);\n    ~AboutDialog();\n\nprivate:\n    Ui::About *ui;\n};\n\n#endif // ABOUTDIALOG_H\n"
  },
  {
    "path": "src/ui/aboutdialog.ui",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<ui version=\"4.0\">\n <class>About</class>\n <widget class=\"QDialog\" name=\"About\">\n  <property name=\"geometry\">\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>616</width>\n    <height>538</height>\n   </rect>\n  </property>\n  <property name=\"windowTitle\">\n   <string>About This Thing</string>\n  </property>\n  <widget class=\"QDialogButtonBox\" name=\"buttonBox\">\n   <property name=\"geometry\">\n    <rect>\n     <x>200</x>\n     <y>500</y>\n     <width>341</width>\n     <height>32</height>\n    </rect>\n   </property>\n   <property name=\"orientation\">\n    <enum>Qt::Horizontal</enum>\n   </property>\n   <property name=\"standardButtons\">\n    <set>QDialogButtonBox::Ok</set>\n   </property>\n  </widget>\n  <widget class=\"QLabel\" name=\"label_logo\">\n   <property name=\"geometry\">\n    <rect>\n     <x>40</x>\n     <y>30</y>\n     <width>501</width>\n     <height>221</height>\n    </rect>\n   </property>\n   <property name=\"text\">\n    <string/>\n   </property>\n   <property name=\"pixmap\">\n    <pixmap resource=\"../resources.qrc\">:/images/images/logo.png</pixmap>\n   </property>\n  </widget>\n  <widget class=\"QLabel\" name=\"label_info\">\n   <property name=\"geometry\">\n    <rect>\n     <x>80</x>\n     <y>280</y>\n     <width>481</width>\n     <height>18</height>\n    </rect>\n   </property>\n   <property name=\"text\">\n    <string>Version %1. Built %2</string>\n   </property>\n  </widget>\n  <widget class=\"QTextBrowser\" name=\"textBrowser\">\n   <property name=\"geometry\">\n    <rect>\n     <x>80</x>\n     <y>300</y>\n     <width>461</width>\n     <height>190</height>\n    </rect>\n   </property>\n   <property name=\"html\">\n    <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;\n&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;\np, li { white-space: pre-wrap; }\n&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;\n&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Legal Information&lt;/span&gt;&lt;/p&gt;\n&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600;&quot;&gt;&lt;/p&gt;\n&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Application Copyright © 2011 Angus Gratton.&lt;/p&gt;\n&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;\n&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;This application incorporates elements of the following  third party Free Software libraries (see below for licensing terms):&lt;/p&gt;\n&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;* &lt;a href=&quot;http://code.google.com/p/qextserialport/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;qextserialport&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;\n&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;* &lt;a href=&quot;http://www.music.mcgill.ca/~gary/rtmidi/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;RtMidi&lt;/span&gt;&lt;/a&gt;: realtime MIDI i/o C++ classes Copyright © 2003-2011 Gary P. Scavone&lt;/p&gt;\n&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;* &lt;a href=&quot;http://qt.nokia.com/products&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;Qt 4.7&lt;/span&gt;&lt;/a&gt; Copyright ©2011 Nokia, Inc.&lt;/p&gt;\n&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;\n&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;License&lt;/span&gt;&lt;/p&gt;\n&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;This application is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the &lt;a href=&quot;http://www.gnu.org/licenses/lgpl-2.1.html&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;GNU Lesser General Public License&lt;/span&gt;&lt;/a&gt; for more details.&lt;/p&gt;\n&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;\n&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;qextserialport &lt;/span&gt;is additionally licensed under the New BSD License&lt;/p&gt;\n&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;\n&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;RtMidi &lt;/span&gt;is additionally licensed as follows: &lt;/p&gt;\n&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Lucida Grande,Verdana,Geneva,Arial,sans-serif'; color:#000000;&quot;&gt;Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the &amp;quot;Software&amp;quot;), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:&lt;/span&gt;&lt;/p&gt;\n&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Lucida Grande,Verdana,Geneva,Arial,sans-serif'; color:#000000;&quot;&gt;The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.&lt;/span&gt;&lt;/p&gt;\n&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Lucida Grande,Verdana,Geneva,Arial,sans-serif'; color:#000000;&quot;&gt;Any person wishing to distribute modifications to the Software is requested to send the modifications to the original developer so that they can be incorporated into the canonical version.&lt;/span&gt;&lt;/p&gt;\n&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Lucida Grande,Verdana,Geneva,Arial,sans-serif'; color:#000000;&quot;&gt;THE SOFTWARE IS PROVIDED &amp;quot;AS IS&amp;quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.&lt;/span&gt;&lt;/p&gt;\n&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;\n&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Qt&lt;/span&gt; is licensed under the GNU Lesser General Public License 2.1&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>\n   </property>\n   <property name=\"openExternalLinks\">\n    <bool>true</bool>\n   </property>\n  </widget>\n  <widget class=\"QLabel\" name=\"HomePageButton\">\n   <property name=\"geometry\">\n    <rect>\n     <x>450</x>\n     <y>280</y>\n     <width>100</width>\n     <height>18</height>\n    </rect>\n   </property>\n   <property name=\"text\">\n    <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;\n&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;\np, li { white-space: pre-wrap; }\n&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;\n&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;a href=&quot;http://projectgus.github.com/hairless-midiserial&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;Home Page&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>\n   </property>\n   <property name=\"openExternalLinks\">\n    <bool>true</bool>\n   </property>\n  </widget>\n </widget>\n <resources>\n  <include location=\"../resources.qrc\"/>\n </resources>\n <connections>\n  <connection>\n   <sender>buttonBox</sender>\n   <signal>accepted()</signal>\n   <receiver>About</receiver>\n   <slot>accept()</slot>\n   <hints>\n    <hint type=\"sourcelabel\">\n     <x>248</x>\n     <y>254</y>\n    </hint>\n    <hint type=\"destinationlabel\">\n     <x>157</x>\n     <y>274</y>\n    </hint>\n   </hints>\n  </connection>\n  <connection>\n   <sender>buttonBox</sender>\n   <signal>rejected()</signal>\n   <receiver>About</receiver>\n   <slot>reject()</slot>\n   <hints>\n    <hint type=\"sourcelabel\">\n     <x>316</x>\n     <y>260</y>\n    </hint>\n    <hint type=\"destinationlabel\">\n     <x>286</x>\n     <y>274</y>\n    </hint>\n   </hints>\n  </connection>\n </connections>\n</ui>\n"
  },
  {
    "path": "src/ui/mainwindow.cpp",
    "content": "#include \"mainwindow.h\"\n#include \"ui_mainwindow.h\"\n#include \"qextserialenumerator.h\"\n#include \"Settings.h\"\n#include \"settingsdialog.h\"\n#include \"aboutdialog.h\"\n\nconst int LIST_REFRESH_RATE =20; // Hz\n\nstatic void selectIfAvailable(QComboBox *box, QString itemText)\n{\n    for(int i = 0; i < box->count(); i++) {\n        if(box->itemText(i) == itemText) {\n            box->setCurrentIndex(i);\n            return;\n        }\n    }\n}\n\nMainWindow::MainWindow(QWidget *parent) :\n    QMainWindow(parent),\n    ui(new Ui::MainWindow),\n    bridge(NULL),\n    workerThread(NULL),\n    debugListTimer(),\n    debugListMessages()\n{\n    ui->setupUi(this);\n    // Fixed width, minimum height\n    this->setMinimumSize(this->size());\n    this->setMaximumSize(this->size().width(), 2000);\n#ifdef Q_OS_LINUX\n    this->setWindowIcon(QIcon(\":/images/images/icon48.png\"));\n#endif\n\n    // Plumb event filter for focus events\n    ui->cmbMidiIn->installEventFilter(this);\n    ui->cmbMidiOut->installEventFilter(this);\n    ui->cmbSerial->installEventFilter(this);\n\n    // Load initial state\n    this->workerThread = new QThread();\n    this->workerThread->start(QThread::HighestPriority);\n    refresh();\n    scrollbackSize=Settings::getScrollbackSize();\n    ui->chk_debug->setChecked( Settings::getDebug() );\n    selectIfAvailable(ui->cmbMidiIn, Settings::getLastMidiIn());\n    selectIfAvailable(ui->cmbMidiOut, Settings::getLastMidiOut());\n    selectIfAvailable(ui->cmbSerial, Settings::getLastSerialPort());\n\n    // Set up timer for the display list\n    debugListTimer.setSingleShot(true);\n    debugListTimer.setInterval(1000 / LIST_REFRESH_RATE);\n\n    // Plumb signals & slots\n    connect(ui->cmbMidiIn, SIGNAL(currentIndexChanged(int)), SLOT(onValueChanged()));\n    connect(ui->cmbMidiOut, SIGNAL(currentIndexChanged(int)), SLOT(onValueChanged()));\n    connect(ui->cmbSerial, SIGNAL(currentIndexChanged(int)), SLOT(onValueChanged()));\n    connect(ui->chk_on, SIGNAL(clicked()), SLOT(onValueChanged()));\n    connect(ui->chk_debug, SIGNAL(clicked(bool)), SLOT(onDebugClicked(bool)));\n    connect(&debugListTimer, SIGNAL(timeout()), SLOT(refreshDebugList()));\n\n\n    // Menu items\n    connect(ui->actionExit, SIGNAL(triggered()), qApp, SLOT(quit()));\n    connect(ui->actionAbout, SIGNAL(triggered()), SLOT(showAboutBox()));\n    connect(ui->actionPreferences, SIGNAL(triggered()), SLOT(showPreferences()));\n\n    // Get started\n    onValueChanged();\n\n#ifdef Q_OS_MAC\n    // hack: avoid an empty dummy File menu on OS X\n    // there might be a better way to do this, but hide() and clear() don't work.\n    ui->menuFile->setTitle(\"\"); // Doesn't do anything on OS X\n#endif\n\n}\n\n\nMainWindow::~MainWindow()\n{\n    bridge->deleteLater();\n    delete ui;\n}\n\nvoid MainWindow::showPreferences()\n{\n    SettingsDialog dialog;\n    if(dialog.exec() == QDialog::Accepted) {\n        scrollbackSize=Settings::getScrollbackSize();\n        onValueChanged();\n    }\n}\n\nvoid MainWindow::showAboutBox()\n{\n    AboutDialog().exec();\n}\n\nbool MainWindow::eventFilter(QObject *object, QEvent *event) {\n    // If user is triggering a dropdown, refresh it live\n    if(event->type() == QEvent::MouseButtonPress || event->type() == QEvent::KeyPress) {\n        if(object == ui->cmbMidiIn) {\n            RtMidiIn in;\n            refreshMidi(ui->cmbMidiIn, &in);\n        } else if (object == ui->cmbMidiOut) {\n            RtMidiOut out;\n            refreshMidi(ui->cmbMidiOut, &out);\n        }\n        else if (object == ui->cmbSerial) {\n            refreshSerial();\n        }\n    }\n    return false;\n}\n\nvoid MainWindow::refresh()\n{\n    refreshSerial();\n    refreshMidiIn();\n    refreshMidiOut();\n}\n\nvoid MainWindow::refreshMidiIn()\n{\n    RtMidiIn in = RtMidiIn();\n    refreshMidi(ui->cmbMidiIn, &in);\n}\n\nvoid MainWindow::refreshMidiOut()\n{\n    RtMidiOut out = RtMidiOut();\n    refreshMidi(ui->cmbMidiOut, &out);\n}\n\n\nvoid MainWindow::refreshMidi(QComboBox *combo, RtMidi *midi)\n{\n    QString current = combo->currentText();\n    combo->clear();\n    try\n    {\n      int ports = midi->getPortCount();\n      combo->addItem(TEXT_NOT_CONNECTED);\n      for (int i = 0; i < ports; i++ ) {\n        QString name = QString::fromStdString(midi->getPortName(i));\n        combo->addItem(name);\n            if(current == name) {\n                combo->setCurrentIndex(combo->count() - 1);\n           }\n        }\n    }\n    catch (RtMidiError err) {\n        ui->lst_debug->addItem(\"Failed to scan for MIDI ports:\");\n        ui->lst_debug->addItem(QString::fromStdString(err.getMessage()));\n        ui->lst_debug->scrollToBottom();\n    }\n}\n\nvoid MainWindow::refreshSerial()\n{\n    QString current = ui->cmbSerial->currentText();\n    ui->cmbSerial->clear();\n    ui->cmbSerial->addItem(TEXT_NOT_CONNECTED);\n    QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();\n    for(QList<QextPortInfo>::iterator it = ports.begin(); it != ports.end(); it++) {\n        QString label = it->friendName.isEmpty() ? it->portName : it->friendName;\n#ifdef Q_OS_LINUX\n        QString portName = it->physName; // Bug workaround, Linux needs the /dev/ in front of port name\n#else\n        QString portName = it->portName;\n#endif\n        ui->cmbSerial->addItem(label, QVariant(portName));\n        if(current == label) {\n            ui->cmbSerial->setCurrentIndex(ui->cmbSerial->count() - 1);\n        }\n    }\n}\n\nvoid MainWindow::onDebugClicked(bool value)\n{\n    Settings::setDebug(value);\n}\n\nvoid MainWindow::onValueChanged()\n{\n    if(bridge) {\n        bridge->deleteLater();\n        QThread::yieldCurrentThread(); // Try and get any signals from the bridge sent sooner not later\n        QCoreApplication::processEvents();\n        bridge = NULL;\n    }\n    Settings::setLastMidiIn(ui->cmbMidiIn->currentText());\n    Settings::setLastMidiOut(ui->cmbMidiOut->currentText());\n    Settings::setLastSerialPort(ui->cmbSerial->currentText());\n    if(!ui->chk_on->isChecked()\n            || ( ui->cmbSerial->currentIndex() == 0\n                    && ui->cmbMidiIn->currentIndex() == 0\n                    && ui->cmbMidiOut->currentIndex() == 0 )) {\n        return;\n    }\n    ui->lst_debug->clear();\n    int midiIn =ui->cmbMidiIn->currentIndex()-1;\n    int midiOut = ui->cmbMidiOut->currentIndex()-1;\n    ui->lst_debug->addItem(\"Starting MIDI<->Serial Bridge...\");\n    bridge = new Bridge();\n    connect(bridge, SIGNAL(debugMessage(QString)), SLOT(onDebugMessage(QString)));\n    connect(bridge, SIGNAL(displayMessage(QString)), SLOT(onDisplayMessage(QString)));\n    connect(bridge, SIGNAL(midiReceived()), ui->led_midiin, SLOT(blinkOn()));\n    connect(bridge, SIGNAL(midiSent()), ui->led_midiout, SLOT(blinkOn()));\n    connect(bridge, SIGNAL(serialTraffic()), ui->led_serial, SLOT(blinkOn()));\n    bridge->attach(ui->cmbSerial->itemData(ui->cmbSerial->currentIndex()).toString(), Settings::getPortSettings(), midiIn, midiOut, workerThread);\n}\n\nvoid MainWindow::onDisplayMessage(QString message)\n{\n    if(debugListMessages.size() == scrollbackSize)\n        debugListMessages.removeFirst();\n    debugListMessages.append(message);\n    if(!debugListTimer.isActive())\n        debugListTimer.start();\n}\n\nvoid MainWindow::onDebugMessage(QString message)\n{\n    if(ui->chk_debug->isChecked())\n        onDisplayMessage(message);\n}\n\n/*\n * When the timer (started in onDisplayMessage) fires, we update lst_debug with the\n * contents of debugListMessages.\n *\n * This happens in the timer event in order to rate limit it to a number of redraws per second\n * (redrawing, and especially scrolling the list view, can be quite resource intensive.)\n */\nvoid MainWindow::refreshDebugList()\n{\n    QListWidget *lst = ui->lst_debug;\n    while(lst->count() + debugListMessages.size() - scrollbackSize > 0 && lst->count() > 0) {\n      delete lst->item(0);\n    }\n    lst->addItems(debugListMessages);\n    debugListMessages.clear();\n    lst->scrollToBottom();\n}\n\nvoid MainWindow::resizeEvent(QResizeEvent *)\n{\n    QListWidget *lst = ui->lst_debug;\n    QRect geo = lst->geometry();\n    geo.setHeight( this->height() - geo.top() - 20 );\n    lst->setGeometry(geo);\n}\n\n"
  },
  {
    "path": "src/ui/mainwindow.h",
    "content": "#ifndef MAINWINDOW_H\n#define MAINWINDOW_H\n\n#include <QMainWindow>\n#include <QComboBox>\n#include <QLabel>\n#include <QTime>\n#include <QMenuBar>\n#include <QTimer>\n#include \"RtMidi.h\"\n#include \"Bridge.h\"\n\nnamespace Ui {\n    class MainWindow;\n}\n\nclass MainWindow : public QMainWindow\n{\n    Q_OBJECT\n\npublic:\n    explicit MainWindow(QWidget *parent = 0);\n    ~MainWindow();\n\n    bool eventFilter(QObject *, QEvent *);\n\n    void resizeEvent(QResizeEvent *);\n\nprivate:\n    Ui::MainWindow *ui;\n    Bridge *bridge;\n    QPixmap pxLedOn;\n    QPixmap pxLedOff;\n    QThread *workerThread;\n    int scrollbackSize;\n    QTimer debugListTimer;\n    QStringList debugListMessages;\n\n    void refresh();\n    void refreshSerial();\n    void refreshMidiIn();\n    void refreshMidiOut();\n    void refreshMidi(QComboBox *combo, RtMidi *midi);\n\nprivate slots:\n    void onValueChanged();\n    void onDisplayMessage(QString message);\n    void onDebugMessage(QString message);\n    void onDebugClicked(bool value);\n    void refreshDebugList();\n    void showPreferences();\n    void showAboutBox();\n};\n\n#endif // MAINWINDOW_H\n"
  },
  {
    "path": "src/ui/mainwindow.ui",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<ui version=\"4.0\">\n <class>MainWindow</class>\n <widget class=\"QMainWindow\" name=\"MainWindow\">\n  <property name=\"geometry\">\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>604</width>\n    <height>278</height>\n   </rect>\n  </property>\n  <property name=\"sizePolicy\">\n   <sizepolicy hsizetype=\"Fixed\" vsizetype=\"Fixed\">\n    <horstretch>0</horstretch>\n    <verstretch>0</verstretch>\n   </sizepolicy>\n  </property>\n  <property name=\"windowTitle\">\n   <string>Hairless MIDI&lt;-&gt;Serial Bridge</string>\n  </property>\n  <widget class=\"QWidget\" name=\"centralWidget\">\n   <widget class=\"QListWidget\" name=\"lst_debug\">\n    <property name=\"geometry\">\n     <rect>\n      <x>10</x>\n      <y>162</y>\n      <width>591</width>\n      <height>81</height>\n     </rect>\n    </property>\n    <property name=\"sizePolicy\">\n     <sizepolicy hsizetype=\"Expanding\" vsizetype=\"Expanding\">\n      <horstretch>0</horstretch>\n      <verstretch>1</verstretch>\n     </sizepolicy>\n    </property>\n    <property name=\"autoScroll\">\n     <bool>true</bool>\n    </property>\n   </widget>\n   <widget class=\"QLabel\" name=\"label_4\">\n    <property name=\"geometry\">\n     <rect>\n      <x>210</x>\n      <y>30</y>\n      <width>201</width>\n      <height>91</height>\n     </rect>\n    </property>\n    <property name=\"text\">\n     <string/>\n    </property>\n    <property name=\"pixmap\">\n     <pixmap resource=\"resources.qrc\">:/images/images/arrows.png</pixmap>\n    </property>\n   </widget>\n   <widget class=\"QLabel\" name=\"label\">\n    <property name=\"geometry\">\n     <rect>\n      <x>10</x>\n      <y>50</y>\n      <width>146</width>\n      <height>17</height>\n     </rect>\n    </property>\n    <property name=\"maximumSize\">\n     <size>\n      <width>212</width>\n      <height>16777215</height>\n     </size>\n    </property>\n    <property name=\"text\">\n     <string>Serial port</string>\n    </property>\n   </widget>\n   <widget class=\"QCheckBox\" name=\"chk_on\">\n    <property name=\"geometry\">\n     <rect>\n      <x>10</x>\n      <y>10</y>\n      <width>185</width>\n      <height>22</height>\n     </rect>\n    </property>\n    <property name=\"text\">\n     <string>Serial&lt;-&gt;MIDI Bridge On</string>\n    </property>\n    <property name=\"checked\">\n     <bool>true</bool>\n    </property>\n   </widget>\n   <widget class=\"QCheckBox\" name=\"chk_debug\">\n    <property name=\"geometry\">\n     <rect>\n      <x>10</x>\n      <y>130</y>\n      <width>201</width>\n      <height>22</height>\n     </rect>\n    </property>\n    <property name=\"text\">\n     <string>Debug MIDI messages</string>\n    </property>\n   </widget>\n   <widget class=\"QComboBox\" name=\"cmbMidiIn\">\n    <property name=\"geometry\">\n     <rect>\n      <x>430</x>\n      <y>100</y>\n      <width>170</width>\n      <height>27</height>\n     </rect>\n    </property>\n   </widget>\n   <widget class=\"QLabel\" name=\"label_2\">\n    <property name=\"geometry\">\n     <rect>\n      <x>430</x>\n      <y>20</y>\n      <width>175</width>\n      <height>17</height>\n     </rect>\n    </property>\n    <property name=\"maximumSize\">\n     <size>\n      <width>212</width>\n      <height>16777215</height>\n     </size>\n    </property>\n    <property name=\"text\">\n     <string>MIDI Out</string>\n    </property>\n   </widget>\n   <widget class=\"QLabel\" name=\"label_3\">\n    <property name=\"geometry\">\n     <rect>\n      <x>430</x>\n      <y>80</y>\n      <width>149</width>\n      <height>17</height>\n     </rect>\n    </property>\n    <property name=\"maximumSize\">\n     <size>\n      <width>212</width>\n      <height>16777215</height>\n     </size>\n    </property>\n    <property name=\"text\">\n     <string>MIDI In</string>\n    </property>\n   </widget>\n   <widget class=\"QComboBox\" name=\"cmbMidiOut\">\n    <property name=\"geometry\">\n     <rect>\n      <x>430</x>\n      <y>40</y>\n      <width>170</width>\n      <height>27</height>\n     </rect>\n    </property>\n   </widget>\n   <widget class=\"QComboBox\" name=\"cmbSerial\">\n    <property name=\"geometry\">\n     <rect>\n      <x>10</x>\n      <y>71</y>\n      <width>170</width>\n      <height>27</height>\n     </rect>\n    </property>\n   </widget>\n   <widget class=\"BlinkenLight\" name=\"led_serial\">\n    <property name=\"geometry\">\n     <rect>\n      <x>185</x>\n      <y>77</y>\n      <width>16</width>\n      <height>16</height>\n     </rect>\n    </property>\n    <property name=\"text\">\n     <string/>\n    </property>\n    <property name=\"pixmap\">\n     <pixmap resource=\"resources.qrc\">:/images/images/led-off.png</pixmap>\n    </property>\n   </widget>\n   <widget class=\"BlinkenLight\" name=\"led_midiout\">\n    <property name=\"geometry\">\n     <rect>\n      <x>410</x>\n      <y>45</y>\n      <width>16</width>\n      <height>16</height>\n     </rect>\n    </property>\n    <property name=\"text\">\n     <string/>\n    </property>\n    <property name=\"pixmap\">\n     <pixmap resource=\"resources.qrc\">:/images/images/led-off.png</pixmap>\n    </property>\n   </widget>\n   <widget class=\"BlinkenLight\" name=\"led_midiin\">\n    <property name=\"geometry\">\n     <rect>\n      <x>410</x>\n      <y>105</y>\n      <width>16</width>\n      <height>16</height>\n     </rect>\n    </property>\n    <property name=\"text\">\n     <string/>\n    </property>\n    <property name=\"pixmap\">\n     <pixmap resource=\"resources.qrc\">:/images/images/led-off.png</pixmap>\n    </property>\n   </widget>\n  </widget>\n  <widget class=\"QMenuBar\" name=\"menuBar\">\n   <property name=\"geometry\">\n    <rect>\n     <x>0</x>\n     <y>0</y>\n     <width>604</width>\n     <height>26</height>\n    </rect>\n   </property>\n   <widget class=\"QMenu\" name=\"menuFile\">\n    <property name=\"title\">\n     <string>File</string>\n    </property>\n    <addaction name=\"actionPreferences\"/>\n    <addaction name=\"separator\"/>\n    <addaction name=\"actionExit\"/>\n   </widget>\n   <widget class=\"QMenu\" name=\"menuHelp\">\n    <property name=\"title\">\n     <string>Help</string>\n    </property>\n    <addaction name=\"actionAbout\"/>\n   </widget>\n   <addaction name=\"menuFile\"/>\n   <addaction name=\"menuHelp\"/>\n  </widget>\n  <action name=\"actionExit\">\n   <property name=\"text\">\n    <string>Exit</string>\n   </property>\n   <property name=\"shortcut\">\n    <string>Ctrl+Q</string>\n   </property>\n  </action>\n  <action name=\"actionAbout\">\n   <property name=\"text\">\n    <string>About Hairless MIDI&lt;-&gt;Serial Bridge...</string>\n   </property>\n  </action>\n  <action name=\"actionPreferences\">\n   <property name=\"text\">\n    <string>Preferences...</string>\n   </property>\n  </action>\n </widget>\n <layoutdefault spacing=\"6\" margin=\"11\"/>\n <customwidgets>\n  <customwidget>\n   <class>BlinkenLight</class>\n   <extends>QLabel</extends>\n   <header>src/BlinkenLight.h</header>\n  </customwidget>\n </customwidgets>\n <tabstops>\n  <tabstop>chk_on</tabstop>\n  <tabstop>cmbSerial</tabstop>\n  <tabstop>cmbMidiOut</tabstop>\n  <tabstop>cmbMidiIn</tabstop>\n  <tabstop>chk_debug</tabstop>\n  <tabstop>lst_debug</tabstop>\n </tabstops>\n <resources>\n  <include location=\"resources.qrc\"/>\n </resources>\n <connections/>\n</ui>\n"
  },
  {
    "path": "src/ui/settingsdialog.cpp",
    "content": "#include \"settingsdialog.h\"\n#include \"ui_settingsdialog.h\"\n#include \"Settings.h\"\n\nstatic void selectByData(QComboBox *box, int dataValue) {\n  for(int i = 0; i < box->count(); i++) {\n      if(box->itemData(i) == dataValue) {\n          box->setCurrentIndex(i);\n          return;\n      }\n  }\n}\n\nstatic void populateBaudRate(QComboBox *box, BaudRateType initialValue)\n{\n#ifdef Q_OS_UNIX\n    box->addItem(\"50\", BAUD50);\n    box->addItem(\"75\", BAUD75);\n#endif\n    box->addItem(\"110\", BAUD110);\n#ifdef Q_OS_UNIX\n    box->addItem(\"134\", BAUD134);\n    box->addItem(\"150\", BAUD150);\n    box->addItem(\"200\", BAUD200);\n#endif\n    box->addItem(\"300\", BAUD300);\n    box->addItem(\"600\", BAUD600);\n    box->addItem(\"1200\", BAUD1200);\n#ifdef Q_OS_UNIX\n    box->addItem(\"1800\", BAUD1800);\n#endif\n    box->addItem(\"2400\", BAUD2400);\n    box->addItem(\"4800\", BAUD4800);\n    box->addItem(\"9600\", BAUD9600);\n#ifdef Q_OS_WIN32\n    box->addItem(\"14400\", BAUD14400);\n#endif\n    box->addItem(\"19200\", BAUD19200);\n    box->addItem(\"38400\", BAUD38400);\n#ifdef Q_OS_WIN32\n    box->addItem(\"56000\", BAUD56000);\n#endif\n    box->addItem(\"57600\", BAUD57600);\n    box->addItem(\"115200\", BAUD115200);\n#ifdef Q_OS_WIN32\n    box->addItem(\"128000\", BAUD128000);\n    box->addItem(\"256000\", BAUD256000);\n#endif\n    selectByData(box, initialValue);\n}\n\nstatic void populateDataBits(QComboBox *box, DataBitsType initialValue)\n{\n    box->addItem(\"5\", DATA_5);\n    box->addItem(\"6\", DATA_6);\n    box->addItem(\"7\", DATA_7);\n    box->addItem(\"8\", DATA_8);\n    selectByData(box, initialValue);\n}\n\nstatic void populateParity(QComboBox *box, ParityType initialValue)\n{\n  box->addItem(\"None\", PAR_NONE);\n  box->addItem(\"Odd\", PAR_ODD);\n  box->addItem(\"Even\", PAR_EVEN);\n#ifdef Q_OS_WIN32\n  box->addItem(\"Mark\", PAR_MARK);\n#endif\n  box->addItem(\"Space\", PAR_SPACE);\n  selectByData(box, initialValue);\n}\n\nstatic void populateStopBits(QComboBox *box, StopBitsType initialValue)\n{\n  box->addItem(\"1\", STOP_1);\n#ifdef Q_OS_WIN32\n  box->addItem(\"1 1/2\", STOP_1_5);\n#endif\n  box->addItem(\"2\", STOP_2);\n  selectByData(box, initialValue);\n}\n\nstatic void populateFlowControl(QComboBox *box, FlowType initialValue)\n{\n  box->addItem(\"None\", FLOW_OFF);\n  box->addItem(\"Hardware\", FLOW_HARDWARE);\n  box->addItem(\"XON/XOFF\", FLOW_XONXOFF);\n  selectByData(box, initialValue);\n}\n\n\nSettingsDialog::SettingsDialog(QWidget *parent) :\n    QDialog(parent),\n    ui(new Ui::SettingsDialog)\n{\n    ui->setupUi(this);\n    ui->spn_scrollback->setValue( Settings::getScrollbackSize() );\n\n    PortSettings port = Settings::getPortSettings();\n    populateBaudRate(ui->cmb_baud, port.BaudRate);\n    populateDataBits(ui->cmb_dataBits, port.DataBits);\n    populateParity(ui->cmb_parity, port.Parity);\n    populateStopBits(ui->cmb_stop, port.StopBits);\n    populateFlowControl(ui->cmb_flow, port.FlowControl);\n\n    connect(ui->btn_defaults, SIGNAL(clicked()), SLOT(resetSerialPort()));\n}\n\nSettingsDialog::~SettingsDialog()\n{\n    delete ui;\n}\n\nstatic int currentData(QComboBox *box) {\n    return box->itemData(box->currentIndex()).toInt();\n}\n\nvoid SettingsDialog::accept()\n{\n    Settings::setScrollbackSize(ui->spn_scrollback->value());\n    PortSettings port;\n    port.BaudRate = (BaudRateType) currentData( ui->cmb_baud );\n    port.DataBits = (DataBitsType) currentData( ui->cmb_dataBits );\n    port.Parity = (ParityType) currentData( ui->cmb_parity );\n    port.StopBits = (StopBitsType) currentData( ui->cmb_stop );\n    port.FlowControl = (FlowType) currentData( ui->cmb_flow );\n    Settings::setPortSettings(port);\n    QDialog::accept();\n}\n\nvoid SettingsDialog::resetSerialPort()\n{\n    selectByData(ui->cmb_baud, BAUD115200);\n    selectByData(ui->cmb_dataBits, DATA_8);\n    selectByData(ui->cmb_parity, PAR_NONE);\n    selectByData(ui->cmb_stop, STOP_1);\n    selectByData(ui->cmb_flow, FLOW_OFF);\n}\n"
  },
  {
    "path": "src/ui/settingsdialog.h",
    "content": "#ifndef SETTINGSDIALOG_H\n#define SETTINGSDIALOG_H\n\n#include <QDialog>\n\nnamespace Ui {\n    class SettingsDialog;\n}\n\nclass SettingsDialog : public QDialog\n{\n    Q_OBJECT\n\npublic:\n    explicit SettingsDialog(QWidget *parent = 0);\n    ~SettingsDialog();\n\nprivate:\n    Ui::SettingsDialog *ui;\n\npublic slots:\n    virtual void accept();\nprivate slots:\n    void resetSerialPort();\n};\n\n#endif // SETTINGSDIALOG_H\n"
  },
  {
    "path": "src/ui/settingsdialog.ui",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<ui version=\"4.0\">\n <class>SettingsDialog</class>\n <widget class=\"QDialog\" name=\"SettingsDialog\">\n  <property name=\"geometry\">\n   <rect>\n    <x>0</x>\n    <y>0</y>\n    <width>379</width>\n    <height>403</height>\n   </rect>\n  </property>\n  <property name=\"windowTitle\">\n   <string>Settings</string>\n  </property>\n  <widget class=\"QDialogButtonBox\" name=\"buttonBox\">\n   <property name=\"geometry\">\n    <rect>\n     <x>20</x>\n     <y>360</y>\n     <width>341</width>\n     <height>32</height>\n    </rect>\n   </property>\n   <property name=\"orientation\">\n    <enum>Qt::Horizontal</enum>\n   </property>\n   <property name=\"standardButtons\">\n    <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>\n   </property>\n  </widget>\n  <widget class=\"QGroupBox\" name=\"groupBox\">\n   <property name=\"geometry\">\n    <rect>\n     <x>20</x>\n     <y>10</y>\n     <width>331</width>\n     <height>241</height>\n    </rect>\n   </property>\n   <property name=\"title\">\n    <string>Serial Port Settings</string>\n   </property>\n   <widget class=\"QWidget\" name=\"formLayoutWidget\">\n    <property name=\"geometry\">\n     <rect>\n      <x>10</x>\n      <y>20</y>\n      <width>311</width>\n      <height>181</height>\n     </rect>\n    </property>\n    <layout class=\"QFormLayout\" name=\"formLayout\">\n     <property name=\"fieldGrowthPolicy\">\n      <enum>QFormLayout::AllNonFixedFieldsGrow</enum>\n     </property>\n     <item row=\"0\" column=\"0\">\n      <widget class=\"QLabel\" name=\"baudRateLabel\">\n       <property name=\"text\">\n        <string>Baud rate</string>\n       </property>\n      </widget>\n     </item>\n     <item row=\"0\" column=\"1\">\n      <widget class=\"QComboBox\" name=\"cmb_baud\"/>\n     </item>\n     <item row=\"1\" column=\"0\">\n      <widget class=\"QLabel\" name=\"dataBitsLabel\">\n       <property name=\"text\">\n        <string>Data Bits</string>\n       </property>\n      </widget>\n     </item>\n     <item row=\"1\" column=\"1\">\n      <widget class=\"QComboBox\" name=\"cmb_dataBits\"/>\n     </item>\n     <item row=\"2\" column=\"0\">\n      <widget class=\"QLabel\" name=\"parityLabel\">\n       <property name=\"text\">\n        <string>Parity</string>\n       </property>\n      </widget>\n     </item>\n     <item row=\"2\" column=\"1\">\n      <widget class=\"QComboBox\" name=\"cmb_parity\"/>\n     </item>\n     <item row=\"3\" column=\"0\">\n      <widget class=\"QLabel\" name=\"stopBitSLabel\">\n       <property name=\"text\">\n        <string>Stop Bit(s)</string>\n       </property>\n      </widget>\n     </item>\n     <item row=\"3\" column=\"1\">\n      <widget class=\"QComboBox\" name=\"cmb_stop\"/>\n     </item>\n     <item row=\"4\" column=\"0\">\n      <widget class=\"QLabel\" name=\"flowControlLabel\">\n       <property name=\"text\">\n        <string>Flow Control</string>\n       </property>\n      </widget>\n     </item>\n     <item row=\"4\" column=\"1\">\n      <widget class=\"QComboBox\" name=\"cmb_flow\"/>\n     </item>\n    </layout>\n   </widget>\n   <widget class=\"QPushButton\" name=\"btn_defaults\">\n    <property name=\"geometry\">\n     <rect>\n      <x>172</x>\n      <y>210</y>\n      <width>141</width>\n      <height>28</height>\n     </rect>\n    </property>\n    <property name=\"text\">\n     <string>Restore Defaults</string>\n    </property>\n   </widget>\n  </widget>\n  <widget class=\"QGroupBox\" name=\"groupBox_2\">\n   <property name=\"geometry\">\n    <rect>\n     <x>20</x>\n     <y>270</y>\n     <width>331</width>\n     <height>71</height>\n    </rect>\n   </property>\n   <property name=\"title\">\n    <string>Debugging Output</string>\n   </property>\n   <widget class=\"QWidget\" name=\"formLayoutWidget_2\">\n    <property name=\"geometry\">\n     <rect>\n      <x>0</x>\n      <y>20</y>\n      <width>321</width>\n      <height>31</height>\n     </rect>\n    </property>\n    <layout class=\"QFormLayout\" name=\"formLayout_2\">\n     <property name=\"fieldGrowthPolicy\">\n      <enum>QFormLayout::AllNonFixedFieldsGrow</enum>\n     </property>\n     <item row=\"0\" column=\"0\">\n      <widget class=\"QLabel\" name=\"linesOfDebugScrollbackLabel\">\n       <property name=\"text\">\n        <string>Lines of Debug Scrollback</string>\n       </property>\n      </widget>\n     </item>\n     <item row=\"0\" column=\"1\">\n      <widget class=\"QSpinBox\" name=\"spn_scrollback\">\n       <property name=\"minimum\">\n        <number>2</number>\n       </property>\n       <property name=\"maximum\">\n        <number>2000</number>\n       </property>\n       <property name=\"singleStep\">\n        <number>10</number>\n       </property>\n       <property name=\"value\">\n        <number>50</number>\n       </property>\n      </widget>\n     </item>\n    </layout>\n   </widget>\n  </widget>\n </widget>\n <tabstops>\n  <tabstop>cmb_baud</tabstop>\n  <tabstop>cmb_dataBits</tabstop>\n  <tabstop>cmb_parity</tabstop>\n  <tabstop>cmb_stop</tabstop>\n  <tabstop>cmb_flow</tabstop>\n  <tabstop>btn_defaults</tabstop>\n  <tabstop>spn_scrollback</tabstop>\n  <tabstop>buttonBox</tabstop>\n </tabstops>\n <resources/>\n <connections>\n  <connection>\n   <sender>buttonBox</sender>\n   <signal>accepted()</signal>\n   <receiver>SettingsDialog</receiver>\n   <slot>accept()</slot>\n   <hints>\n    <hint type=\"sourcelabel\">\n     <x>238</x>\n     <y>334</y>\n    </hint>\n    <hint type=\"destinationlabel\">\n     <x>157</x>\n     <y>274</y>\n    </hint>\n   </hints>\n  </connection>\n  <connection>\n   <sender>buttonBox</sender>\n   <signal>rejected()</signal>\n   <receiver>SettingsDialog</receiver>\n   <slot>reject()</slot>\n   <hints>\n    <hint type=\"sourcelabel\">\n     <x>306</x>\n     <y>340</y>\n    </hint>\n    <hint type=\"destinationlabel\">\n     <x>286</x>\n     <y>274</y>\n    </hint>\n   </hints>\n  </connection>\n  <connection>\n   <sender>buttonBox</sender>\n   <signal>accepted()</signal>\n   <receiver>SettingsDialog</receiver>\n   <slot>accept()</slot>\n   <hints>\n    <hint type=\"sourcelabel\">\n     <x>242</x>\n     <y>348</y>\n    </hint>\n    <hint type=\"destinationlabel\">\n     <x>259</x>\n     <y>318</y>\n    </hint>\n   </hints>\n  </connection>\n </connections>\n</ui>\n"
  }
]