Compare commits

...

29 Commits

Author SHA1 Message Date
c41ee27069 Restricted external processors to unlocked sentences 2019-01-07 16:51:51 +00:00
e5b395ffa5 Added external processors 2019-01-07 15:45:52 +00:00
b55f76c855 Add edit in external editor 2019-01-07 13:17:36 +00:00
28a8bd3c51 Checkpoint release 2018-11-14 15:58:25 +00:00
9adcd89cd5 Added groundwork for multiple EQ profiles 2018-11-14 12:00:19 +00:00
14e6709c29 Added gain control and normalization, along with peak display 2018-11-13 13:26:54 +00:00
024626019d Added overlay icons 2018-11-03 11:58:04 +00:00
c0d86d5753 Merge branch 'master' of github.com:MajenkoProjects/AudiobookRecorder 2018-10-29 15:34:19 +00:00
175281537c Added ethereal voice effect 2018-10-29 15:33:25 +00:00
Matt Jenkins
abb26288c6 Added book name to start of exported chapters 2018-10-22 14:08:16 +01:00
f5c0d5bbfc Dumped Sphinx and instead using Haven OnDemand speech API 2018-10-21 13:52:20 +01:00
ff08db3e44 Added book info edit option 2018-10-06 21:30:58 +01:00
7431550d61 Added ACX website connections 2018-10-06 20:47:22 +01:00
448910b8d7 Put options and EQ panels in scroll panes 2018-10-04 20:38:09 +01:00
991c4fbf8e Updated locked theme 2018-10-04 00:33:00 +01:00
ced0aaa597 Added attention flag 2018-10-04 00:26:16 +01:00
498247c793 Removed enable/disable of toolbar buttons and fixed broken playback controls 2018-10-03 15:47:10 +01:00
ad5c3808cd Merge branch 'master' of github.com:MajenkoProjects/AudiobookRecorder 2018-10-03 12:42:29 +01:00
c658dc6a50 Added archive path to options 2018-10-03 12:41:38 +01:00
Matt Jenkins
100adec397 Added desktop file 2018-10-02 23:18:12 +01:00
Matt Jenkins
f4b793574d Added build instructions to README 2018-10-02 23:08:31 +01:00
d8c52575fb Move jars to LFS 2018-10-02 22:41:39 +01:00
1b2945d9c4 Added LFS 2018-10-02 22:40:01 +01:00
1244bd60ed Decimate by 4 2018-10-02 22:37:31 +01:00
b566b9e89e Add book name to window title 2018-10-02 15:39:20 +01:00
4a4d7f2a38 Checkpoint release 2018-10-02 14:37:23 +01:00
f7848228a2 Added cover art import #6 2018-10-02 14:36:37 +01:00
8c22315b15 Added import archive #4 2018-10-02 14:21:12 +01:00
718c982578 Added batch conversion of text #8 2018-10-02 12:00:11 +01:00
65 changed files with 4831 additions and 416 deletions

1
.gitattributes vendored Normal file
View File

@@ -0,0 +1 @@
*.jar filter=lfs diff=lfs merge=lfs -text

View File

@@ -72,3 +72,15 @@ files) is placed.
When you export the book as MP3 a new folder "export" is created within the book's folder where the MP3 files are placed. When you export the book as MP3 a new folder "export" is created within the book's folder where the MP3 files are placed.
MP3 files are all tagged with the book title, chapter title, chapter number and comment. MP3 files are all tagged with the book title, chapter title, chapter number and comment.
Building
========
1. Check out this repo
2. Install `ant` and `default-jdk`
3. Install [git LFS support](https://help.github.com/articles/installing-git-large-file-storage/)
4. Pull the large files with `git lfs pull`
5. Build with `ant build`
6. Run with `java -jar ./AudiobookRecorder.jar`

Binary file not shown.

BIN
deps/commons-codec-1.10.jar LFS vendored Normal file

Binary file not shown.

BIN
deps/commons-logging-1.2.jar LFS vendored Normal file

Binary file not shown.

BIN
deps/fluent-hc-4.5.6.jar LFS vendored Normal file

Binary file not shown.

BIN
deps/httpclient-4.5.6.jar LFS vendored Normal file

Binary file not shown.

BIN
deps/httpclient-cache-4.5.6.jar LFS vendored Normal file

Binary file not shown.

BIN
deps/httpclient-win-4.5.6.jar LFS vendored Normal file

Binary file not shown.

BIN
deps/httpcore-4.4.10.jar LFS vendored Normal file

Binary file not shown.

BIN
deps/httpmime-4.5.6.jar LFS vendored Normal file

Binary file not shown.

BIN
deps/jna-4.4.0.jar LFS vendored Normal file

Binary file not shown.

BIN
deps/jna-platform-4.4.0.jar LFS vendored Normal file

Binary file not shown.

BIN
deps/json-20180813.jar LFS vendored Normal file

Binary file not shown.

BIN
deps/mp3agic-0.9.1.jar vendored

Binary file not shown.

Binary file not shown.

Binary file not shown.

13
dist/linux/audiobookrecorder.desktop vendored Normal file
View File

@@ -0,0 +1,13 @@
[Desktop Entry]
Name=AudiobookRecorder
GenericName=Audiobook Recorder
X-GNOME-FullName=AudiobookRecorder
Comment=Record audiobooks with ease
Keywords=audio
Exec=AudiobookRecorder
Terminal=false
Type=Application
StartupNotify=true
Icon=AudiobookRecorder
Categories=AudioVideo;Audio;Recorder;
X-AppStream-Ignore=true

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,558 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
=========================================================================
This project includes Public Suffix List copied from
<https://publicsuffix.org/list/effective_tld_names.dat>
licensed under the terms of the Mozilla Public License, v. 2.0
Full license text: <http://mozilla.org/MPL/2.0/>
Mozilla Public License Version 2.0
==================================
1. Definitions
--------------
1.1. "Contributor"
means each individual or legal entity that creates, contributes to
the creation of, or owns Covered Software.
1.2. "Contributor Version"
means the combination of the Contributions of others (if any) used
by a Contributor and that particular Contributor's Contribution.
1.3. "Contribution"
means Covered Software of a particular Contributor.
1.4. "Covered Software"
means Source Code Form to which the initial Contributor has attached
the notice in Exhibit A, the Executable Form of such Source Code
Form, and Modifications of such Source Code Form, in each case
including portions thereof.
1.5. "Incompatible With Secondary Licenses"
means
(a) that the initial Contributor has attached the notice described
in Exhibit B to the Covered Software; or
(b) that the Covered Software was made available under the terms of
version 1.1 or earlier of the License, but not also under the
terms of a Secondary License.
1.6. "Executable Form"
means any form of the work other than Source Code Form.
1.7. "Larger Work"
means a work that combines Covered Software with other material, in
a separate file or files, that is not Covered Software.
1.8. "License"
means this document.
1.9. "Licensable"
means having the right to grant, to the maximum extent possible,
whether at the time of the initial grant or subsequently, any and
all of the rights conveyed by this License.
1.10. "Modifications"
means any of the following:
(a) any file in Source Code Form that results from an addition to,
deletion from, or modification of the contents of Covered
Software; or
(b) any new file in Source Code Form that contains any Covered
Software.
1.11. "Patent Claims" of a Contributor
means any patent claim(s), including without limitation, method,
process, and apparatus claims, in any patent Licensable by such
Contributor that would be infringed, but for the grant of the
License, by the making, using, selling, offering for sale, having
made, import, or transfer of either its Contributions or its
Contributor Version.
1.12. "Secondary License"
means either the GNU General Public License, Version 2.0, the GNU
Lesser General Public License, Version 2.1, the GNU Affero General
Public License, Version 3.0, or any later versions of those
licenses.
1.13. "Source Code Form"
means the form of the work preferred for making modifications.
1.14. "You" (or "Your")
means an individual or a legal entity exercising rights under this
License. For legal entities, "You" includes any entity that
controls, is controlled by, or is under common control with You. For
purposes of this definition, "control" means (a) the power, direct
or indirect, to cause the direction or management of such entity,
whether by contract or otherwise, or (b) ownership of more than
fifty percent (50%) of the outstanding shares or beneficial
ownership of such entity.
2. License Grants and Conditions
--------------------------------
2.1. Grants
Each Contributor hereby grants You a world-wide, royalty-free,
non-exclusive license:
(a) under intellectual property rights (other than patent or trademark)
Licensable by such Contributor to use, reproduce, make available,
modify, display, perform, distribute, and otherwise exploit its
Contributions, either on an unmodified basis, with Modifications, or
as part of a Larger Work; and
(b) under Patent Claims of such Contributor to make, use, sell, offer
for sale, have made, import, and otherwise transfer either its
Contributions or its Contributor Version.
2.2. Effective Date
The licenses granted in Section 2.1 with respect to any Contribution
become effective for each Contribution on the date the Contributor first
distributes such Contribution.
2.3. Limitations on Grant Scope
The licenses granted in this Section 2 are the only rights granted under
this License. No additional rights or licenses will be implied from the
distribution or licensing of Covered Software under this License.
Notwithstanding Section 2.1(b) above, no patent license is granted by a
Contributor:
(a) for any code that a Contributor has removed from Covered Software;
or
(b) for infringements caused by: (i) Your and any other third party's
modifications of Covered Software, or (ii) the combination of its
Contributions with other software (except as part of its Contributor
Version); or
(c) under Patent Claims infringed by Covered Software in the absence of
its Contributions.
This License does not grant any rights in the trademarks, service marks,
or logos of any Contributor (except as may be necessary to comply with
the notice requirements in Section 3.4).
2.4. Subsequent Licenses
No Contributor makes additional grants as a result of Your choice to
distribute the Covered Software under a subsequent version of this
License (see Section 10.2) or under the terms of a Secondary License (if
permitted under the terms of Section 3.3).
2.5. Representation
Each Contributor represents that the Contributor believes its
Contributions are its original creation(s) or it has sufficient rights
to grant the rights to its Contributions conveyed by this License.
2.6. Fair Use
This License is not intended to limit any rights You have under
applicable copyright doctrines of fair use, fair dealing, or other
equivalents.
2.7. Conditions
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
in Section 2.1.
3. Responsibilities
-------------------
3.1. Distribution of Source Form
All distribution of Covered Software in Source Code Form, including any
Modifications that You create or to which You contribute, must be under
the terms of this License. You must inform recipients that the Source
Code Form of the Covered Software is governed by the terms of this
License, and how they can obtain a copy of this License. You may not
attempt to alter or restrict the recipients' rights in the Source Code
Form.
3.2. Distribution of Executable Form
If You distribute Covered Software in Executable Form then:
(a) such Covered Software must also be made available in Source Code
Form, as described in Section 3.1, and You must inform recipients of
the Executable Form how they can obtain a copy of such Source Code
Form by reasonable means in a timely manner, at a charge no more
than the cost of distribution to the recipient; and
(b) You may distribute such Executable Form under the terms of this
License, or sublicense it under different terms, provided that the
license for the Executable Form does not attempt to limit or alter
the recipients' rights in the Source Code Form under this License.
3.3. Distribution of a Larger Work
You may create and distribute a Larger Work under terms of Your choice,
provided that You also comply with the requirements of this License for
the Covered Software. If the Larger Work is a combination of Covered
Software with a work governed by one or more Secondary Licenses, and the
Covered Software is not Incompatible With Secondary Licenses, this
License permits You to additionally distribute such Covered Software
under the terms of such Secondary License(s), so that the recipient of
the Larger Work may, at their option, further distribute the Covered
Software under the terms of either this License or such Secondary
License(s).
3.4. Notices
You may not remove or alter the substance of any license notices
(including copyright notices, patent notices, disclaimers of warranty,
or limitations of liability) contained within the Source Code Form of
the Covered Software, except that You may alter any license notices to
the extent required to remedy known factual inaccuracies.
3.5. Application of Additional Terms
You may choose to offer, and to charge a fee for, warranty, support,
indemnity or liability obligations to one or more recipients of Covered
Software. However, You may do so only on Your own behalf, and not on
behalf of any Contributor. You must make it absolutely clear that any
such warranty, support, indemnity, or liability obligation is offered by
You alone, and You hereby agree to indemnify every Contributor for any
liability incurred by such Contributor as a result of warranty, support,
indemnity or liability terms You offer. You may include additional
disclaimers of warranty and limitations of liability specific to any
jurisdiction.
4. Inability to Comply Due to Statute or Regulation
---------------------------------------------------
If it is impossible for You to comply with any of the terms of this
License with respect to some or all of the Covered Software due to
statute, judicial order, or regulation then You must: (a) comply with
the terms of this License to the maximum extent possible; and (b)
describe the limitations and the code they affect. Such description must
be placed in a text file included with all distributions of the Covered
Software under this License. Except to the extent prohibited by statute
or regulation, such description must be sufficiently detailed for a
recipient of ordinary skill to be able to understand it.
5. Termination
--------------
5.1. The rights granted under this License will terminate automatically
if You fail to comply with any of its terms. However, if You become
compliant, then the rights granted under this License from a particular
Contributor are reinstated (a) provisionally, unless and until such
Contributor explicitly and finally terminates Your grants, and (b) on an
ongoing basis, if such Contributor fails to notify You of the
non-compliance by some reasonable means prior to 60 days after You have
come back into compliance. Moreover, Your grants from a particular
Contributor are reinstated on an ongoing basis if such Contributor
notifies You of the non-compliance by some reasonable means, this is the
first time You have received notice of non-compliance with this License
from such Contributor, and You become compliant prior to 30 days after
Your receipt of the notice.
5.2. If You initiate litigation against any entity by asserting a patent
infringement claim (excluding declaratory judgment actions,
counter-claims, and cross-claims) alleging that a Contributor Version
directly or indirectly infringes any patent, then the rights granted to
You by any and all Contributors for the Covered Software under Section
2.1 of this License shall terminate.
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
end user license agreements (excluding distributors and resellers) which
have been validly granted by You or Your distributors under this License
prior to termination shall survive termination.
************************************************************************
* *
* 6. Disclaimer of Warranty *
* ------------------------- *
* *
* Covered Software is provided under this License on an "as is" *
* basis, without warranty of any kind, either expressed, implied, or *
* statutory, including, without limitation, warranties that the *
* Covered Software is free of defects, merchantable, fit for a *
* particular purpose or non-infringing. The entire risk as to the *
* quality and performance of the Covered Software is with You. *
* Should any Covered Software prove defective in any respect, You *
* (not any Contributor) assume the cost of any necessary servicing, *
* repair, or correction. This disclaimer of warranty constitutes an *
* essential part of this License. No use of any Covered Software is *
* authorized under this License except under this disclaimer. *
* *
************************************************************************
************************************************************************
* *
* 7. Limitation of Liability *
* -------------------------- *
* *
* Under no circumstances and under no legal theory, whether tort *
* (including negligence), contract, or otherwise, shall any *
* Contributor, or anyone who distributes Covered Software as *
* permitted above, be liable to You for any direct, indirect, *
* special, incidental, or consequential damages of any character *
* including, without limitation, damages for lost profits, loss of *
* goodwill, work stoppage, computer failure or malfunction, or any *
* and all other commercial damages or losses, even if such party *
* shall have been informed of the possibility of such damages. This *
* limitation of liability shall not apply to liability for death or *
* personal injury resulting from such party's negligence to the *
* extent applicable law prohibits such limitation. Some *
* jurisdictions do not allow the exclusion or limitation of *
* incidental or consequential damages, so this exclusion and *
* limitation may not apply to You. *
* *
************************************************************************
8. Litigation
-------------
Any litigation relating to this License may be brought only in the
courts of a jurisdiction where the defendant maintains its principal
place of business and such litigation shall be governed by laws of that
jurisdiction, without reference to its conflict-of-law provisions.
Nothing in this Section shall prevent a party's ability to bring
cross-claims or counter-claims.
9. Miscellaneous
----------------
This License represents the complete agreement concerning the subject
matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent
necessary to make it enforceable. Any law or regulation which provides
that the language of a contract shall be construed against the drafter
shall not be used to construe this License against a Contributor.
10. Versions of the License
---------------------------
10.1. New Versions
Mozilla Foundation is the license steward. Except as provided in Section
10.3, no one other than the license steward has the right to modify or
publish new versions of this License. Each version will be given a
distinguishing version number.
10.2. Effect of New Versions
You may distribute the Covered Software under the terms of the version
of the License under which You originally received the Covered Software,
or under the terms of any subsequent version published by the license
steward.
10.3. Modified Versions
If you create software not governed by this License, and you want to
create a new license for such software, you may create and use a
modified version of this License if you rename the license and remove
any references to the name of the license steward (except to note that
such modified license differs from this License).
10.4. Distributing Source Code Form that is Incompatible With Secondary
Licenses
If You choose to distribute Source Code Form that is Incompatible With
Secondary Licenses under the terms of this version of the License, the
notice described in Exhibit B of this License must be attached.
Exhibit A - Source Code Form License Notice
-------------------------------------------
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
If it is not possible or desirable to put the notice in a particular
file, then You may include the notice in a location (such as a LICENSE
file in a relevant directory) where a recipient would be likely to look
for such a notice.
You may add additional accurate notices of copyright ownership.
Exhibit B - "Incompatible With Secondary Licenses" Notice
---------------------------------------------------------
This Source Code Form is "Incompatible With Secondary Licenses", as
defined by the Mozilla Public License, v. 2.0.

View File

@@ -0,0 +1,6 @@
Apache HttpComponents Client
Copyright 1999-2018 The Apache Software Foundation
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).

View File

@@ -0,0 +1,77 @@
Apache HttpComponents Client
============================
Welcome to the HttpClient component of the Apache HttpComponents project.
Building Instructions
---------------------
For building from source instructions please refer to BUILDING.txt.
Dependencies
------------
HttpClient main module requires Java 6 compatible runtime and
depends on the following external libraries:
* Apache HttpComponents HttpCore
* Apache Commons Logging
* Apache Commons Codec
(for detailed information on external dependencies please see pom.xml)
HttpMime module is optional and requires Java 6 compatible runtime
and depends on the following external libraries:
* Apache HttpComponents HttpCore
* Apache Commons Logging
(for detailed information on external dependencies please see pom.xml)
Licensing
---------
Apache HttpComponents Client is licensed under the Apache License 2.0.
See the files called LICENSE.txt and NOTICE.txt for more information.
Cryptographic Software Notice
-----------------------------
This distribution may include software that has been designed for use
with cryptographic software. The country in which you currently reside
may have restrictions on the import, possession, use, and/or re-export
to another country, of encryption software. BEFORE using any encryption
software, please check your country's laws, regulations and policies
concerning the import, possession, or use, and re-export of encryption
software, to see if this is permitted. See <http://www.wassenaar.org/>
for more information.
The U.S. Government Department of Commerce, Bureau of Industry and
Security (BIS), has classified this software as Export Commodity
Control Number (ECCN) 5D002.C.1, which includes information security
software using or performing cryptographic functions with asymmetric
algorithms. The form and manner of this Apache Software Foundation
distribution makes it eligible for export under the License Exception
ENC Technology Software Unrestricted (TSU) exception (see the BIS
Export Administration Regulations, Section 740.13) for both object
code and source code.
The following provides more details on the included software that
may be subject to export controls on cryptographic software:
Apache HttpComponents Client interfaces with the
Java Secure Socket Extension (JSSE) API to provide
- HTTPS support
Apache HttpComponents Client does not include any
implementation of JSSE.
Contact
-------
o For general information visit the main project site at
http://hc.apache.org/
o For current status information visit the status page at
http://hc.apache.org/status.html

File diff suppressed because it is too large Load Diff

View File

@@ -1 +1 @@
version=0.1.0 version=0.1.4

Binary file not shown.

After

Width:  |  Height:  |  Size: 952 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 838 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 277 B

After

Width:  |  Height:  |  Size: 263 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 592 B

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 473 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 799 B

After

Width:  |  Height:  |  Size: 710 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 301 B

File diff suppressed because it is too large Load Diff

View File

@@ -17,6 +17,7 @@ public class Book extends DefaultMutableTreeNode {
String author; String author;
String genre; String genre;
String comment; String comment;
String ACX;
int sampleRate; int sampleRate;
int channels; int channels;
@@ -24,39 +25,31 @@ public class Book extends DefaultMutableTreeNode {
ImageIcon icon; ImageIcon icon;
public Equaliser equaliser; public Equaliser[] equaliser = new Equaliser[2];
float[] eqChannels = new float[31]; float[] eqChannels = new float[31];
public Book(String bookname) { Properties prefs;
public Book(Properties p, String bookname) {
super(bookname); super(bookname);
prefs = p;
name = bookname; name = bookname;
equaliser = new Equaliser(); equaliser[0] = new Equaliser("Default");
equaliser[1] = new Equaliser("Phone");
AudiobookRecorder.window.setTitle("AudioBook Recorder :: " + name);
} }
public void setAuthor(String a) { public void setAuthor(String a) { author = a; }
author = a; public void setGenre(String g) { genre = g; }
} public void setComment(String c) { comment = c; }
public void setACX(String c) { ACX = c; }
public void setGenre(String g) { public String getAuthor() { return author; }
genre = g; public String getGenre() { return genre; }
} public String getComment() { return comment; }
public String getACX() { if (ACX == null) return ""; return ACX; }
public void setComment(String c) {
comment = c;
}
public String getAuthor() {
return author;
}
public String getGenre() {
return genre;
}
public String getComment() {
return comment;
}
public Chapter getClosingCredits() { public Chapter getClosingCredits() {
return getChapterById("close"); return getChapterById("close");
@@ -124,23 +117,28 @@ public class Book extends DefaultMutableTreeNode {
public void setUserObject(Object o) { public void setUserObject(Object o) {
if (o instanceof String) { if (o instanceof String) {
String newName = (String)o; String newName = (String)o;
if (newName.equals(name)) return;
renameBook(newName);
}
}
File oldDir = new File(Options.get("path.storage"), name); public void renameBook(String newName) {
File newDir = new File(Options.get("path.storage"), newName); File oldDir = new File(Options.get("path.storage"), name);
File newDir = new File(Options.get("path.storage"), newName);
if (newDir.exists()) { if (newDir.exists()) {
JOptionPane.showMessageDialog(AudiobookRecorder.window, "Book already exists", "Error", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(AudiobookRecorder.window, "Book already exists", "Error", JOptionPane.ERROR_MESSAGE);
return; return;
} }
if (oldDir.exists() && oldDir.isDirectory()) { if (oldDir.exists() && oldDir.isDirectory()) {
oldDir.renameTo(newDir); oldDir.renameTo(newDir);
name = newName; name = newName;
AudiobookRecorder.window.saveBookStructure(); AudiobookRecorder.window.saveBookStructure();
AudiobookRecorder.window.bookTreeModel.reload(this); AudiobookRecorder.window.bookTreeModel.reload(this);
Options.set("path.last-book", name); Options.set("path.last-book", name);
Options.savePreferences(); Options.savePreferences();
} AudiobookRecorder.window.setTitle("AudioBook Recorder :: " + name);
} }
} }
@@ -171,4 +169,22 @@ public class Book extends DefaultMutableTreeNode {
public AudioFormat getAudioFormat() { public AudioFormat getAudioFormat() {
return new AudioFormat(getSampleRate(), getResolution(), getChannels(), true, false); return new AudioFormat(getSampleRate(), getResolution(), getChannels(), true, false);
} }
public String get(String key) {
if (prefs.getProperty(key) == null) { return Options.get(key); }
return prefs.getProperty(key);
}
public Integer getInteger(String key) {
if (prefs.getProperty(key) == null) { return Options.getInteger(key); }
return Utils.s2i(prefs.getProperty(key));
}
public void set(String key, String value) {
prefs.setProperty(key, value);
}
public void set(String key, Integer value) {
prefs.setProperty(key, "" + value);
}
} }

View File

@@ -4,6 +4,7 @@ import javax.swing.*;
import javax.swing.event.*; import javax.swing.event.*;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.util.regex.*;
public class BookInfoPanel extends JPanel { public class BookInfoPanel extends JPanel {
@@ -11,8 +12,9 @@ public class BookInfoPanel extends JPanel {
JTextField author; JTextField author;
JTextField genre; JTextField genre;
JTextField comment; JTextField comment;
JTextField acx;
public BookInfoPanel(String t, String a, String g, String c) { public BookInfoPanel(String t, String a, String g, String c, String x) {
super(); super();
setLayout(new GridBagLayout()); setLayout(new GridBagLayout());
GridBagConstraints con = new GridBagConstraints(); GridBagConstraints con = new GridBagConstraints();
@@ -56,37 +58,36 @@ public class BookInfoPanel extends JPanel {
con.gridx = 0; con.gridx = 0;
con.gridy++; con.gridy++;
add(new JLabel("AXC Code:"), con);
con.gridx = 1;
acx = new JTextField(x);
acx.setPreferredSize(new Dimension(200, 20));
add(acx, con);
con.gridx = 0;
con.gridy++;
} }
public String getTitle() { public String getTitle() { return title.getText(); }
return title.getText(); public String getAuthor() { return author.getText(); }
public String getGenre() { return genre.getText(); }
public String getComment() { return comment.getText(); }
public String getACX() {
Pattern p = Pattern.compile("\\/titleview\\/([A-Z0-9]{14})");
Matcher m = p.matcher(acx.getText());
if (m.find()) {
System.err.println(m);
return m.group(1);
}
return acx.getText();
} }
public String getAuthor() { public void setTitle(String t) { title.setText(t); }
return author.getText(); public void setAuthor(String a) { author.setText(a); }
} public void setGenre(String g) { genre.setText(g); }
public void setComment(String c) { comment.setText(c); }
public void setACX(String a) { acx.setText(a); }
public String getGenre() {
return genre.getText();
}
public String getComment() {
return comment.getText();
}
public void setTitle(String t) {
title.setText(t);
}
public void setAuthor(String a) {
author.setText(a);
}
public void setGenre(String g) {
genre.setText(g);
}
public void setComment(String c) {
comment.setText(c);
}
} }

View File

@@ -28,30 +28,48 @@ public class BookPanel extends JPanel {
boolean highlight = false; boolean highlight = false;
public BookPanel(Properties p, ImageIcon i) {
loadBookData(p, i);
}
public BookPanel(File r) { public BookPanel(File r) {
try { try {
root = r; root = r;
Properties props = new Properties(); Properties props = new Properties();
props.loadFromXML(new FileInputStream(new File(root, "audiobook.abk"))); props.loadFromXML(new FileInputStream(new File(root, "audiobook.abk")));
loadBookData(props, null);
} catch (Exception e) {
e.printStackTrace();
}
}
public void loadBookData(Properties props, ImageIcon i) {
try {
name = props.getProperty("book.name"); name = props.getProperty("book.name");
author = props.getProperty("book.author"); author = props.getProperty("book.author");
genre = props.getProperty("book.genre"); genre = props.getProperty("book.genre");
comment = props.getProperty("book.comment"); comment = props.getProperty("book.comment");
File icon = new File(root, "coverart.png"); if (i == null) {
if (!icon.exists()) { File icon = new File(root, "coverart.png");
icon = new File(root, "coverart.jpg"); if (!icon.exists()) {
} icon = new File(root, "coverart.jpg");
if (!icon.exists()) { }
icon = new File(root, "coverart.gif"); if (!icon.exists()) {
} icon = new File(root, "coverart.gif");
if (icon.exists()) { }
cover = new ImageIcon(icon.getAbsolutePath()); if (icon.exists()) {
cover = new ImageIcon(icon.getAbsolutePath());
resizedCover = Utils.getScaledImage(cover.getImage(), 75, 75);
iconLabel = new JLabel(new ImageIcon(resizedCover));
} else {
cover = null;
resizedCover = null;
iconLabel = new JLabel("");
}
} else {
cover = i;
resizedCover = Utils.getScaledImage(cover.getImage(), 75, 75); resizedCover = Utils.getScaledImage(cover.getImage(), 75, 75);
iconLabel = new JLabel(new ImageIcon(resizedCover)); iconLabel = new JLabel(new ImageIcon(resizedCover));
} else {
cover = null;
resizedCover = null;
iconLabel = new JLabel("");
} }
iconLabel.setSize(new Dimension(75, 75)); iconLabel.setSize(new Dimension(75, 75));

View File

@@ -11,19 +11,32 @@ public class BookTreeRenderer extends DefaultTreeCellRenderer {
if (value instanceof Sentence) { if (value instanceof Sentence) {
Sentence s = (Sentence)value; Sentence s = (Sentence)value;
if (s.isLocked()) { OverlayIcon icn = new OverlayIcon(Icons.sentence);
ret.setForeground(new Color(0x20, 0x00, 0x00));
ret.setIcon(Icons.locked); if (s.getOverrideText() != null) {
} else if (s.getStartOffset() == 0) { ret.setText(s.getOverrideText());
ret.setIcon(Icons.important);
} else {
ret.setIcon(Icons.sentence);
} }
if (s.isInSample()) { if (s.getAttentionFlag()) {
ret.setIcon(Icons.star); ret.setForeground(new Color(0xFF, 0xFF, 0x00));
icn.add(Overlays.attention, OverlayIcon.TOP_LEFT);
}
if (s.isLocked()) {
ret.setForeground(new Color(0x00, 0x80, 0xFF));
icn.add(Overlays.locked, OverlayIcon.BOTTOM_LEFT);
}
if (s.getStartOffset() == 0) {
icn.add(Overlays.important, OverlayIcon.TOP_RIGHT);
}
if (s.getEthereal()) {
icn.add(Overlays.filter, OverlayIcon.BOTTOM_RIGHT);
} }
ret.setIcon(icn);
} else if (value instanceof Chapter) { } else if (value instanceof Chapter) {
ret.setIcon(Icons.chapter); ret.setIcon(Icons.chapter);
} else if (value instanceof Book) { } else if (value instanceof Book) {

View File

@@ -135,7 +135,7 @@ public class Chapter extends DefaultMutableTreeNode {
File exportFile = new File(export, name + ".wax"); File exportFile = new File(export, name + ".wax");
File wavFile = new File(export, name + ".wav"); File wavFile = new File(export, name + ".wav");
File mp3File = new File(export, name + "-untagged.mp3"); File mp3File = new File(export, name + "-untagged.mp3");
File taggedFile = new File(export, name + ".mp3"); File taggedFile = new File(export, book.getName() + " - " + name + ".mp3");
FileOutputStream fos = new FileOutputStream(exportFile); FileOutputStream fos = new FileOutputStream(exportFile);
data = AudiobookRecorder.window.getRoomNoise(Utils.s2i(Options.get("catenation.pre-chapter"))); data = AudiobookRecorder.window.getRoomNoise(Utils.s2i(Options.get("catenation.pre-chapter")));

View File

@@ -40,12 +40,7 @@ public class DonationPanel extends JPanel {
JButton donate = new JButton("Donate!"); JButton donate = new JButton("Donate!");
donate.addActionListener(new ActionListener() { donate.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (Desktop.isDesktopSupported()) { Utils.browse("https://paypal.me/majenko");
try {
Desktop.getDesktop().browse(new URI("https://paypal.me/majenko"));
} catch (Exception ex) {
}
}
} }
}); });

View File

@@ -14,6 +14,7 @@ import davaguine.jeq.core.IIRControls;
public class Equaliser extends JPanel { public class Equaliser extends JPanel {
EqualiserChannel channels[]; EqualiserChannel channels[];
String name;
static final double[] frequencies = { static final double[] frequencies = {
20d, 25d, 31.5d, 40d, 50d, 63d, 80d, 100d, 125d, 160d, 200d, 20d, 25d, 31.5d, 40d, 50d, 63d, 80d, 100d, 125d, 160d, 200d,
@@ -22,9 +23,11 @@ public class Equaliser extends JPanel {
20000d 20000d
}; };
public Equaliser() { public Equaliser(String n) {
super(); super();
name = n;
channels = new EqualiserChannel[31]; channels = new EqualiserChannel[31];
setLayout(new BorderLayout()); setLayout(new BorderLayout());
@@ -96,4 +99,8 @@ public class Equaliser extends JPanel {
} }
} }
} }
public String getName() {
return name;
}
} }

View File

@@ -0,0 +1,83 @@
package uk.co.majenko.audiobookrecorder;
import java.util.*;
import java.util.concurrent.*;
import javax.swing.*;
import java.awt.*;
import java.util.Timer;
public class HavenQueue extends JPanel {
ConcurrentLinkedQueue<Sentence> sentenceList = new ConcurrentLinkedQueue<Sentence>();
Timer timer = new Timer();
Sentence currentSentence = null;
JLabel count;
public HavenQueue() {
timer.schedule(new TimerTask() { public void run() { processQueue(); }}, 30000);
count = new JLabel("Haven queue: 0");
setLayout(new BorderLayout());
add(count, BorderLayout.CENTER);
count.setOpaque(false);
setOpaque(false);
count.setForeground(Color.WHITE);
}
public void processQueue() {
count.setText("Haven queue: " + sentenceList.size());
if (currentSentence == null) {
// Grab a new sentence to process.
currentSentence = sentenceList.poll();
if (currentSentence != null) {
if (!currentSentence.postHavenData()) { // Failed. Add to the end of the queue and wait a bit
submit(currentSentence);
currentSentence = null;
timer.schedule(new TimerTask() { public void run() { processQueue(); }}, 30000);
return;
}
timer.schedule(new TimerTask() { public void run() { processQueue(); }}, 5000);
return;
}
timer.schedule(new TimerTask() { public void run() { processQueue(); }}, 5000);
return;
}
if (currentSentence != null) {
currentSentence.processPendingHaven();
int status = currentSentence.getHavenStatus();
switch (status) {
case 0: // Um... not running...?
currentSentence = null;
timer.schedule(new TimerTask() { public void run() { processQueue(); }}, 30000);
return;
case 1: // Still processing...
timer.schedule(new TimerTask() { public void run() { processQueue(); }}, 5000);
return;
case 2: // Finished
currentSentence = null;
timer.schedule(new TimerTask() { public void run() { processQueue(); }}, 30000);
return;
case 3: // Failed
currentSentence = null;
timer.schedule(new TimerTask() { public void run() { processQueue(); }}, 30000);
return;
}
}
timer.schedule(new TimerTask() { public void run() { processQueue(); }}, 30000);
}
public void submit(Sentence s) {
s.setOverrideText("[queued...]");
AudiobookRecorder.window.bookTreeModel.reload(s);
sentenceList.add(s);
count.setText("Haven queue: " + sentenceList.size());
}
}

View File

@@ -31,4 +31,6 @@ public class Icons {
static public final ImageIcon zoomIn = new ImageIcon(Icons.class.getResource("icons/zoom-in.png")); static public final ImageIcon zoomIn = new ImageIcon(Icons.class.getResource("icons/zoom-in.png"));
static public final ImageIcon zoomOut = new ImageIcon(Icons.class.getResource("icons/zoom-out.png")); static public final ImageIcon zoomOut = new ImageIcon(Icons.class.getResource("icons/zoom-out.png"));
static public final ImageIcon dollar = new ImageIcon(Icons.class.getResource("icons/dollar.png")); static public final ImageIcon dollar = new ImageIcon(Icons.class.getResource("icons/dollar.png"));
static public final ImageIcon attention = new ImageIcon(Icons.class.getResource("icons/attention.png"));
static public final ImageIcon normalize = new ImageIcon(Icons.class.getResource("icons/normalize.png"));
} }

View File

@@ -0,0 +1,31 @@
package uk.co.majenko.audiobookrecorder;
public class KVPair<K,V> implements Comparable {
public K key;
public V value;
public KVPair(K k, V v) {
key = k;
value = v;
}
public String toString() {
return (String)value;
}
public int compareTo(Object o) {
// if (o instanceof KVPair) {
// KVPair ko = (KVPair)o;
// return key.compareTo(ko.key);
// }
return 0;
}
public K getKey() {
return key;
}
public V getValue() {
return value;
}
}

View File

@@ -124,31 +124,4 @@ public class MainToolBar extends JToolBar {
setFloatable(false); setFloatable(false);
} }
public void enableBook() {
newChapter.setEnabled(true);
recordRoomNoise.setEnabled(true);
}
public void disableBook() {
newChapter.setEnabled(false);
recordRoomNoise.setEnabled(false);
}
public void enableSentence() {
playSentence.setEnabled(true);
playonSentence.setEnabled(true);
}
public void disableSentence() {
playSentence.setEnabled(false);
playonSentence.setEnabled(false);
}
public void enableStop() {
stopPlaying.setEnabled(true);
}
public void disableStop() {
stopPlaying.setEnabled(false);
}
} }

View File

@@ -22,6 +22,7 @@ public class Options extends JDialog {
JComboBox<KVPair> bitDepth; JComboBox<KVPair> bitDepth;
JComboBox<KVPair> trimMethod; JComboBox<KVPair> trimMethod;
JTextField storageFolder; JTextField storageFolder;
JTextField archiveFolder;
JSpinner preChapterGap; JSpinner preChapterGap;
JSpinner postChapterGap; JSpinner postChapterGap;
JSpinner postSentenceGap; JSpinner postSentenceGap;
@@ -33,35 +34,23 @@ public class Options extends JDialog {
JCheckBox enableParsing; JCheckBox enableParsing;
JSpinner cacheSize; JSpinner cacheSize;
JSpinner etherealIterations;
JSpinner etherealAttenuation;
JSpinner etherealOffset;
JTextField havenApiKey;
JTextField externalEditor;
Equaliser equaliser; Equaliser equaliser;
JTextArea startupScript; JTextArea startupScript;
ArrayList<JTextField[]> processorList;
static HashMap<String, String> defaultPrefs; static HashMap<String, String> defaultPrefs;
static Preferences prefs = null; static Preferences prefs = null;
static class KVPair implements Comparable {
public String key;
public String value;
public KVPair(String k, String v) {
key = k;
value = v;
}
public String toString() {
return value;
}
public int compareTo(Object o) {
if (o instanceof KVPair) {
KVPair ko = (KVPair)o;
return key.compareTo(ko.key);
}
return 0;
}
}
class JButtonObject extends JButton { class JButtonObject extends JButton {
Object object; Object object;
public JButtonObject(String s, Object o) { public JButtonObject(String s, Object o) {
@@ -97,6 +86,61 @@ public class Options extends JDialog {
return o; return o;
} }
void addTwoLabel(JPanel panel, String label1, String label2) {
JLabel l1 = new JLabel(label1);
constraint.gridx = 0;
constraint.gridwidth = 1;
constraint.gridheight = 1;
constraint.anchor = GridBagConstraints.LINE_START;
panel.add(l1, constraint);
JLabel l2 = new JLabel(label2);
constraint.gridx = 1;
constraint.gridwidth = 1;
constraint.gridheight = 1;
constraint.anchor = GridBagConstraints.LINE_START;
panel.add(l2, constraint);
constraint.gridy++;
}
JTextField addTextField(JPanel panel, String label, String def) {
JLabel l = new JLabel(label);
constraint.gridx = 0;
constraint.gridwidth = 1;
constraint.gridheight = 1;
constraint.anchor = GridBagConstraints.LINE_START;
panel.add(l, constraint);
JTextField a = new JTextField(def);
constraint.gridx = 1;
constraint.fill = GridBagConstraints.HORIZONTAL;
panel.add(a, constraint);
constraint.fill = GridBagConstraints.NONE;
constraint.gridy++;
return a;
}
JTextField[] addTwoField(JPanel panel, String def1, String def2) {
JTextField a = new JTextField(def1);
constraint.gridx = 0;
constraint.fill = GridBagConstraints.HORIZONTAL;
panel.add(a, constraint);
JTextField b = new JTextField(def2);
constraint.gridx = 1;
panel.add(b, constraint);
constraint.fill = GridBagConstraints.NONE;
constraint.gridy++;
return new JTextField[] { a, b };
}
JTextField addFilePath(JPanel panel, String label, String path, boolean dironly) { JTextField addFilePath(JPanel panel, String label, String path, boolean dironly) {
JLabel l = new JLabel(label); JLabel l = new JLabel(label);
constraint.gridx = 0; constraint.gridx = 0;
@@ -256,6 +300,7 @@ public class Options extends JDialog {
playbackList = addDropdown(optionsPanel, "Playback device:", getPlaybackMixerList(), get("audio.playback.device")); playbackList = addDropdown(optionsPanel, "Playback device:", getPlaybackMixerList(), get("audio.playback.device"));
addSeparator(optionsPanel); addSeparator(optionsPanel);
storageFolder = addFilePath(optionsPanel, "Storage folder:", get("path.storage"), true); storageFolder = addFilePath(optionsPanel, "Storage folder:", get("path.storage"), true);
archiveFolder = addFilePath(optionsPanel, "Archive folder:", get("path.archive"), true);
addSeparator(optionsPanel); addSeparator(optionsPanel);
@@ -274,34 +319,84 @@ public class Options extends JDialog {
addSeparator(optionsPanel); addSeparator(optionsPanel);
enableParsing = addCheckBox(optionsPanel, "Enable automatic sphinx speech-to-text (**SLOW**)", getBoolean("process.sphinx")); enableParsing = addCheckBox(optionsPanel, "Enable automatic speech-to-text submission", getBoolean("process.haven.auto"));
havenApiKey = addTextField(optionsPanel, "Haven OnDemand API Key", get("process.haven.apikey"));
addSeparator(optionsPanel);
externalEditor = addTextField(optionsPanel, "External Editor Command", get("editor.external"));
addSeparator(optionsPanel); addSeparator(optionsPanel);
cacheSize = addSpinner(optionsPanel, "Cache size:", 0, 5000, 1, getInteger("cache.size"), ""); cacheSize = addSpinner(optionsPanel, "Cache size:", 0, 5000, 1, getInteger("cache.size"), "");
addSeparator(optionsPanel); addSeparator(optionsPanel);
tabs.add("Options", new JScrollPane(optionsPanel));
tabs.add("Options", optionsPanel); equaliser = new Equaliser("Default");
equaliser = new Equaliser();
for (int i = 0; i < 31; i++) { for (int i = 0; i < 31; i++) {
equaliser.setChannel(i, Options.getFloat("audio.eq." + i)); equaliser.setChannel(i, Options.getFloat("audio.eq." + i));
} }
tabs.add("Default EQ", new JScrollPane(equaliser));
tabs.add("Default EQ", equaliser);
JPanel startScript = new JPanel(); JPanel startScript = new JPanel();
startScript.setLayout(new BorderLayout()); startScript.setLayout(new BorderLayout());
startupScript = new JTextArea(get("scripts.startup")); startupScript = new JTextArea(get("scripts.startup"));
startScript.add(startupScript, BorderLayout.CENTER); startScript.add(startupScript, BorderLayout.CENTER);
tabs.add("Startup Script", startScript); tabs.add("Startup Script", startScript);
add(tabs, BorderLayout.CENTER);
JPanel effects = new JPanel();
effects.setLayout(new GridBagLayout());
constraint.gridx = 0;
constraint.gridy = 0;
constraint.gridwidth = 1;
constraint.gridheight = 1;
etherealOffset = addSpinner(effects, "Ethereal Voice Offset", 0, 2000, 10, getInteger("effects.ethereal.offset"), "ms");
etherealIterations = addSpinner(effects, "Ethereal Voice Iterations", 1, 10, 1, getInteger("effects.ethereal.iterations"), "");
etherealAttenuation = addSpinner(effects, "Ethereal Voice Attenuation", 0, 100, 1, getInteger("effects.ethereal.attenuation"), "%");
tabs.add("Effects", effects);
JPanel processors = new JPanel();
processors.setLayout(new BorderLayout());
JPanel processorListPanel = new JPanel();
JScrollPane psp = new JScrollPane(processorListPanel);
processors.add(psp, BorderLayout.CENTER);
processorListPanel.setLayout(new GridBagLayout());
constraint.gridx = 0;
constraint.gridy = 0;
constraint.gridwidth = 1;
constraint.gridheight = 1;
addTwoLabel(processorListPanel, "Name", "Command");
processorList = new ArrayList<JTextField[]>();
for (int i = 0; i < 999; i++) {
String name = get("editor.processor." + i + ".name");
String command = get("editor.processor." + i + ".command");
if (name == null || command == null) break;
if (name.equals("") || command.equals("")) break;
JTextField[] f = addTwoField(processorListPanel, name, command);
processorList.add(f);
}
JTextField[] f = addTwoField(processorListPanel, "", "");
processorList.add(f);
tabs.add("Processors", processors);
add(tabs, BorderLayout.CENTER);
setTitle("Options"); setTitle("Options");
@@ -345,8 +440,8 @@ public class Options extends JDialog {
setVisible(true); setVisible(true);
} }
static KVPair[] getRecordingMixerList() { static KVPair<String, String>[] getRecordingMixerList() {
TreeSet<KVPair> list = new TreeSet<KVPair>(); TreeSet<KVPair<String, String>> list = new TreeSet<KVPair<String, String>>();
AudioFormat stereoFormat = new AudioFormat(44100f, 16, 2, true, false); AudioFormat stereoFormat = new AudioFormat(44100f, 16, 2, true, false);
AudioFormat monoFormat = new AudioFormat(44100f, 16, 1, true, false); AudioFormat monoFormat = new AudioFormat(44100f, 16, 1, true, false);
@@ -373,7 +468,7 @@ public class Options extends JDialog {
} }
if (supported) { if (supported) {
KVPair p = new KVPair(i.getName(), i.getName()); //i.getDescription()); KVPair<String, String> p = new KVPair<String, String>(i.getName(), i.getName()); //i.getDescription());
list.add(p); list.add(p);
} }
} }
@@ -382,7 +477,7 @@ public class Options extends JDialog {
} }
static KVPair[] getPlaybackMixerList() { static KVPair[] getPlaybackMixerList() {
TreeSet<KVPair> list = new TreeSet<KVPair>(); TreeSet<KVPair<String, String>> list = new TreeSet<KVPair<String, String>>();
AudioFormat stereoFormat = new AudioFormat(44100f, 16, 2, true, false); AudioFormat stereoFormat = new AudioFormat(44100f, 16, 2, true, false);
AudioFormat monoFormat = new AudioFormat(44100f, 16, 1, true, false); AudioFormat monoFormat = new AudioFormat(44100f, 16, 1, true, false);
@@ -410,7 +505,7 @@ public class Options extends JDialog {
if (supported) { if (supported) {
KVPair p = new KVPair(i.getName(), i.getName()); //i.getDescription()); KVPair<String, String> p = new KVPair<String, String>(i.getName(), i.getName()); //i.getDescription());
list.add(p); list.add(p);
} }
} }
@@ -420,16 +515,16 @@ public class Options extends JDialog {
static KVPair[] getChannelCountList() { static KVPair[] getChannelCountList() {
KVPair[] l = new KVPair[2]; KVPair[] l = new KVPair[2];
l[0] = new KVPair("1", "Mono"); l[0] = new KVPair<String, String>("1", "Mono");
l[1] = new KVPair("2", "Stereo"); l[1] = new KVPair<String, String>("2", "Stereo");
return l; return l;
} }
static KVPair[] getSampleRateList() { static KVPair[] getSampleRateList() {
KVPair[] l = new KVPair[3]; KVPair[] l = new KVPair[3];
l[0] = new KVPair("44100", "44100"); l[0] = new KVPair<String, String>("44100", "44100");
l[1] = new KVPair("48000", "48000"); l[1] = new KVPair<String, String>("48000", "48000");
l[2] = new KVPair("96000", "96000"); l[2] = new KVPair<String, String>("96000", "96000");
return l; return l;
} }
@@ -441,7 +536,7 @@ public class Options extends JDialog {
KVPair[] playbackMixers = getPlaybackMixerList(); KVPair[] playbackMixers = getPlaybackMixerList();
if (recordingMixers.length > 0) { if (recordingMixers.length > 0) {
defaultPrefs.put("audio.recording.device", recordingMixers[0].key); defaultPrefs.put("audio.recording.device", (String)recordingMixers[0].key);
} else { } else {
defaultPrefs.put("audio.recording.device", ""); defaultPrefs.put("audio.recording.device", "");
} }
@@ -450,7 +545,7 @@ public class Options extends JDialog {
defaultPrefs.put("audio.recording.resolution", "16"); defaultPrefs.put("audio.recording.resolution", "16");
defaultPrefs.put("audio.recording.trim", "peak"); defaultPrefs.put("audio.recording.trim", "peak");
if (playbackMixers.length > 0) { if (playbackMixers.length > 0) {
defaultPrefs.put("audio.playback.device", playbackMixers[0].key); defaultPrefs.put("audio.playback.device", (String)playbackMixers[0].key);
} else { } else {
defaultPrefs.put("audio.playback.device", ""); defaultPrefs.put("audio.playback.device", "");
} }
@@ -462,12 +557,16 @@ public class Options extends JDialog {
defaultPrefs.put("catenation.post-paragraph", "2000"); defaultPrefs.put("catenation.post-paragraph", "2000");
defaultPrefs.put("path.storage", (new File(System.getProperty("user.home"), "Recordings")).toString()); defaultPrefs.put("path.storage", (new File(System.getProperty("user.home"), "Recordings")).toString());
defaultPrefs.put("path.archive", (new File(new File(System.getProperty("user.home"), "Recordings"),"archive")).toString());
defaultPrefs.put("path.ffmpeg", ""); defaultPrefs.put("path.ffmpeg", "");
defaultPrefs.put("audio.export.bitrate", "256000"); defaultPrefs.put("audio.export.bitrate", "256000");
defaultPrefs.put("audio.export.samplerate", "44100"); defaultPrefs.put("audio.export.samplerate", "44100");
defaultPrefs.put("process.sphinx", "false"); defaultPrefs.put("process.sphinx", "false");
defaultPrefs.put("process.haven.apikey", "");
defaultPrefs.put("editor.external", "");
defaultPrefs.put("cache.size", "100"); defaultPrefs.put("cache.size", "100");
@@ -505,6 +604,10 @@ public class Options extends JDialog {
defaultPrefs.put("scripts.startup", ""); defaultPrefs.put("scripts.startup", "");
defaultPrefs.put("effects.ethereal.offset", "50");
defaultPrefs.put("effects.ethereal.iterations", "3");
defaultPrefs.put("effects.ethereal.attenuation", "50");
if (prefs == null) { if (prefs == null) {
prefs = Preferences.userNodeForPackage(AudiobookRecorder.class); prefs = Preferences.userNodeForPackage(AudiobookRecorder.class);
} }
@@ -598,6 +701,7 @@ public class Options extends JDialog {
set("audio.recording.trim", ((KVPair)trimMethod.getSelectedItem()).key); set("audio.recording.trim", ((KVPair)trimMethod.getSelectedItem()).key);
set("audio.playback.device", ((KVPair)playbackList.getSelectedItem()).key); set("audio.playback.device", ((KVPair)playbackList.getSelectedItem()).key);
set("path.storage", storageFolder.getText()); set("path.storage", storageFolder.getText());
set("path.archive", archiveFolder.getText());
set("path.ffmpeg", ffmpegLocation.getText()); set("path.ffmpeg", ffmpegLocation.getText());
set("catenation.pre-chapter", preChapterGap.getValue()); set("catenation.pre-chapter", preChapterGap.getValue());
set("catenation.post-chapter", postChapterGap.getValue()); set("catenation.post-chapter", postChapterGap.getValue());
@@ -607,14 +711,32 @@ public class Options extends JDialog {
set("audio.export.bitrate", ((KVPair)bitRate.getSelectedItem()).key); set("audio.export.bitrate", ((KVPair)bitRate.getSelectedItem()).key);
set("audio.export.samplerate", ((KVPair)exportRate.getSelectedItem()).key); set("audio.export.samplerate", ((KVPair)exportRate.getSelectedItem()).key);
set("process.sphinx", enableParsing.isSelected()); set("process.sphinx", enableParsing.isSelected());
set("process.haven.apikey", havenApiKey.getText());
set("editor.external", externalEditor.getText());
set("cache.size", cacheSize.getValue()); set("cache.size", cacheSize.getValue());
set("effects.ethereal.offset", etherealOffset.getValue());
set("effects.ethereal.iterations", etherealIterations.getValue());
set("effects.ethereal.attenuation", etherealAttenuation.getValue());
for (int i = 0; i < 31; i++) { for (int i = 0; i < 31; i++) {
set("audio.eq." + i, equaliser.getChannel(i)); set("audio.eq." + i, equaliser.getChannel(i));
} }
set("scripts.startup", startupScript.getText()); set("scripts.startup", startupScript.getText());
int procNo = 0;
for (JTextField[] proc : processorList) {
String name = proc[0].getText();
String command = proc[1].getText();
if (name.equals("") || command.equals("")) {
continue;
}
set("editor.processor." + procNo + ".name", name);
set("editor.processor." + procNo + ".command", command);
procNo++;
}
savePreferences(); savePreferences();
} }
@@ -648,23 +770,23 @@ public class Options extends JDialog {
public static KVPair[] getBitrates() { public static KVPair[] getBitrates() {
KVPair[] pairs = new KVPair[4]; KVPair[] pairs = new KVPair[4];
pairs[0] = new KVPair("128000", "128kbps"); pairs[0] = new KVPair<String, String>("128000", "128kbps");
pairs[1] = new KVPair("192000", "192kbps"); pairs[1] = new KVPair<String, String>("192000", "192kbps");
pairs[2] = new KVPair("256000", "256kbps"); pairs[2] = new KVPair<String, String>("256000", "256kbps");
pairs[3] = new KVPair("320000", "320kbps"); pairs[3] = new KVPair<String, String>("320000", "320kbps");
return pairs; return pairs;
} }
public static KVPair[] getResolutionList() { public static KVPair[] getResolutionList() {
KVPair[] pairs = new KVPair[1]; KVPair[] pairs = new KVPair[1];
pairs[0] = new KVPair("16", "16 Bit"); pairs[0] = new KVPair<String, String>("16", "16 Bit");
return pairs; return pairs;
} }
public static KVPair[] getTrimMethods() { public static KVPair[] getTrimMethods() {
KVPair[] pairs = new KVPair[2]; KVPair[] pairs = new KVPair[2];
pairs[0] = new KVPair("peak", "Peak Amplitude"); pairs[0] = new KVPair<String, String>("peak", "Peak Amplitude");
pairs[1] = new KVPair("fft", "FFT Analysis"); pairs[1] = new KVPair<String, String>("fft", "FFT Analysis");
return pairs; return pairs;
} }
} }

View File

@@ -0,0 +1,131 @@
/*
* Copyright (c) 2015, Majenko Technologies
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* * Neither the name of Majenko Technologies nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package uk.co.majenko.audiobookrecorder;
import javax.swing.ImageIcon;
import java.util.List;
import java.util.ArrayList;
import java.awt.Component;
import java.awt.Graphics;
public class OverlayIcon extends ImageIcon {
class IconSpec {
public ImageIcon icon;
int location;
public IconSpec(ImageIcon i, int loc) {
icon = i;
location = loc;
}
}
private ImageIcon base;
private ArrayList<IconSpec> overlays;
public static final int TOP_LEFT = 0;
public static final int TOP_MIDDLE = 1;
public static final int TOP_RIGHT = 2;
public static final int MIDDLE_LEFT = 3;
public static final int MIDDLE_MIDDLE = 4;
public static final int MIDDLE_RIGHT = 5;
public static final int BOTTOM_LEFT = 6;
public static final int BOTTOM_MIDDLE = 7;
public static final int BOTTOM_RIGHT = 8;
public OverlayIcon(ImageIcon base) {
super(base.getImage());
this.base = base;
this.overlays = new ArrayList<IconSpec>();
}
public void add(ImageIcon overlay, int position) {
overlays.add(new IconSpec(overlay, position));
}
@Override
public synchronized void paintIcon(Component c, Graphics g, int x, int y) {
base.paintIcon(c, g, x, y);
int bw = base.getIconWidth();
int bh = base.getIconHeight();
for(IconSpec icon : overlays) {
int iw = icon.icon.getIconWidth();
int ih = icon.icon.getIconHeight();
int ix = 0;
int iy = 0;
switch (icon.location) {
case TOP_LEFT:
case MIDDLE_LEFT:
case BOTTOM_LEFT:
ix = 0;
break;
case TOP_MIDDLE:
case MIDDLE_MIDDLE:
case BOTTOM_MIDDLE:
ix = (bw / 2) - (iw / 2);
break;
case TOP_RIGHT:
case MIDDLE_RIGHT:
case BOTTOM_RIGHT:
ix = bw - iw;
break;
}
switch (icon.location) {
case TOP_LEFT:
case TOP_MIDDLE:
case TOP_RIGHT:
iy = 0;
break;
case MIDDLE_LEFT:
case MIDDLE_MIDDLE:
case MIDDLE_RIGHT:
iy = (bh / 2) - (ih / 2);
break;
case BOTTOM_LEFT:
case BOTTOM_MIDDLE:
case BOTTOM_RIGHT:
iy = bh - ih;
break;
}
icon.icon.paintIcon(c, g, x + ix, y + iy);
}
}
}

View File

@@ -0,0 +1,11 @@
package uk.co.majenko.audiobookrecorder;
import javax.swing.*;
public class Overlays {
static public final ImageIcon locked = new ImageIcon(Overlays.class.getResource("overlays/locked.png"));
static public final ImageIcon star = new ImageIcon(Overlays.class.getResource("overlays/star.png"));
static public final ImageIcon important = new ImageIcon(Overlays.class.getResource("overlays/important.png"));
static public final ImageIcon attention = new ImageIcon(Overlays.class.getResource("overlays/attention.png"));
static public final ImageIcon filter = new ImageIcon(Overlays.class.getResource("overlays/filter.png"));
}

View File

@@ -44,6 +44,7 @@ public class ProgressDialog extends JDialog implements EncoderProgressListener {
pack(); pack();
setSize(new Dimension(300, 100)); setSize(new Dimension(300, 100));
setResizable(false);
// setVisible(true); // setVisible(true);
} }

View File

@@ -9,12 +9,25 @@ import java.io.*;
import java.nio.file.*; import java.nio.file.*;
import javax.swing.tree.*; import javax.swing.tree.*;
import javax.sound.sampled.*; import javax.sound.sampled.*;
import edu.cmu.sphinx.api.*;
import edu.cmu.sphinx.decoder.adaptation.*;
import edu.cmu.sphinx.result.*;
import davaguine.jeq.spi.EqualizerInputStream; import davaguine.jeq.spi.EqualizerInputStream;
import davaguine.jeq.core.IIRControls; import davaguine.jeq.core.IIRControls;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.json.*;
import java.util.Timer;
public class Sentence extends DefaultMutableTreeNode implements Cacheable { public class Sentence extends DefaultMutableTreeNode implements Cacheable {
String text; String text;
@@ -32,6 +45,24 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
boolean recording; boolean recording;
boolean inSample; boolean inSample;
boolean attention = false;
int eqProfile = 0;
double gain = 1.0d;
String havenJobId = "";
// 0: Not processed
// 1: Submitted
// 2: Procesisng finished
// 3: Processing failed
int havenStatus = 0;
String overrideText = null;
public void setOverrideText(String s) { overrideText = s; }
public String getOverrideText() { return overrideText; }
TargetDataLine line; TargetDataLine line;
AudioInputStream inputStream; AudioInputStream inputStream;
@@ -42,6 +73,8 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
RecordingThread recordingThread; RecordingThread recordingThread;
boolean effectEthereal = false;
static class RecordingThread implements Runnable { static class RecordingThread implements Runnable {
boolean running = false; boolean running = false;
@@ -159,7 +192,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
} else if (tm.equals("fft")) { } else if (tm.equals("fft")) {
autoTrimSampleFFT(); autoTrimSampleFFT();
} }
if (Options.getBoolean("process.sphinx")) { if (Options.getBoolean("process.haven.auto")) {
recognise(); recognise();
} }
} }
@@ -329,6 +362,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
} }
public void setText(String t) { public void setText(String t) {
overrideText = null;
text = t; text = t;
} }
@@ -392,6 +426,10 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
} }
public int[] getAudioDataS16LE(AudioInputStream s, AudioFormat format) throws IOException { public int[] getAudioDataS16LE(AudioInputStream s, AudioFormat format) throws IOException {
return getAudioDataS16LE(s, format, true);
}
public int[] getAudioDataS16LE(AudioInputStream s, AudioFormat format, boolean amplify) throws IOException {
long len = s.getFrameLength(); long len = s.getFrameLength();
int frameSize = format.getFrameSize(); int frameSize = format.getFrameSize();
int chans = format.getChannels(); int chans = format.getChannels();
@@ -411,7 +449,12 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
} else { } else {
sample = (frame[1] << 8) | frame[0]; sample = (frame[1] << 8) | frame[0];
} }
samples[(int)fno] = sample; if (amplify) {
double amped = (double)sample * gain;
samples[(int)fno] = (int)amped;
} else {
samples[(int)fno] = sample;
}
} }
return samples; return samples;
@@ -445,6 +488,28 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
return null; return null;
} }
public int[] getUnprocessedAudioData() {
File f = getFile();
try {
AudioInputStream s = AudioSystem.getAudioInputStream(f);
AudioFormat format = getAudioFormat();
int[] samples = null;
switch (format.getSampleSizeInBits()) {
case 16:
samples = getAudioDataS16LE(s, format, false);
break;
}
s.close();
return samples;
} catch (Exception e) {
}
return null;
}
public int getStartCrossing() { public int getStartCrossing() {
return crossStartOffset; return crossStartOffset;
} }
@@ -508,7 +573,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
EqualizerInputStream eq = new EqualizerInputStream(s, 31); EqualizerInputStream eq = new EqualizerInputStream(s, 31);
AudioFormat format = getAudioFormat(); AudioFormat format = getAudioFormat();
IIRControls controls = eq.getControls(); IIRControls controls = eq.getControls();
AudiobookRecorder.window.book.equaliser.apply(controls, format.getChannels()); AudiobookRecorder.window.book.equaliser[eqProfile].apply(controls, format.getChannels());
int frameSize = format.getFrameSize(); int frameSize = format.getFrameSize();
@@ -546,7 +611,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
AudioFormat format = getAudioFormat(); AudioFormat format = getAudioFormat();
IIRControls controls = eq.getControls(); IIRControls controls = eq.getControls();
AudiobookRecorder.window.book.equaliser.apply(controls, format.getChannels()); AudiobookRecorder.window.book.equaliser[eqProfile].apply(controls, format.getChannels());
int frameSize = format.getFrameSize(); int frameSize = format.getFrameSize();
int length = crossEndOffset - crossStartOffset; int length = crossEndOffset - crossStartOffset;
@@ -566,6 +631,8 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
bytesToRead--; bytesToRead--;
} }
} }
data = postProcessData(data);
return data; return data;
} catch (Exception e) { } catch (Exception e) {
@@ -574,70 +641,112 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
return null; return null;
} }
public void recognise() { byte[] adjustGain(byte[] data) {
AudioFormat format = getAudioFormat();
int frameSize = format.getFrameSize();
int channels = format.getChannels();
int bytesPerChannel = frameSize / channels;
int frames = data.length / frameSize;
Thread t = new Thread(new Runnable() { int byteNo = 0;
public void run() { byte[] out = new byte[data.length];
try {
Configuration sphinxConfig = new Configuration(); for (int i = 0; i < frames; i++) {
if (channels == 1) {
int l = data[i * frameSize] >= 0 ? data[i * frameSize] : 256 + data[i * frameSize];
int h = data[(i * frameSize) + 1] >= 0 ? data[(i * frameSize) + 1] : 256 + data[(i * frameSize) + 1];
sphinxConfig.setAcousticModelPath("resource:/edu/cmu/sphinx/models/en-us/en-us"); int sample = (h << 8) | l;
sphinxConfig.setDictionaryPath("resource:/edu/cmu/sphinx/models/en-us/cmudict-en-us.dict"); if ((sample & 0x8000) == 0x8000) sample |= 0xFFFF0000;
sphinxConfig.setLanguageModelPath("resource:/edu/cmu/sphinx/models/en-us/en-us.lm.bin");
double sampleDouble = (double)sample;
sampleDouble *= gain;
sample = (int)sampleDouble;
StreamSpeechRecognizer recognizer; if (sample > 32767) sample = 32767;
if (sample < -32768) sample = -32768;
recognizer = new StreamSpeechRecognizer(sphinxConfig); out[i * frameSize] = (byte)(sample & 0xFF);
out[(i * frameSize) + 1] = (byte)((sample & 0xFF00) >> 8);
AudioInputStream s = AudioSystem.getAudioInputStream(getFile());
AudioFormat format = getAudioFormat();
int frameSize = format.getFrameSize();
int length = (int)s.getFrameLength();
byte[] data = new byte[length * frameSize];
s.read(data);
int channels = format.getChannels();
int newLen = (length / 3);
byte[] decimated = new byte[newLen * 2];
for (int i = 0; i < newLen; i++) {
if (channels == 1) {
decimated[i * 2] = data[i * 6];
decimated[i * 2 + 1] = data[i * 6 + 1];
} else {
decimated[i * 2] = data[i * 12];
decimated[i * 2 + 1] = data[i * 12 + 1];
}
}
ByteArrayInputStream bas = new ByteArrayInputStream(decimated);
recognizer.startRecognition(bas);
SpeechResult result;
String res = "";
while ((result = recognizer.getResult()) != null) {
res += result.getHypothesis();
res += " ";
}
recognizer.stopRecognition();
text = res;
AudiobookRecorder.window.bookTreeModel.reload(Sentence.this);
} catch (Exception e) {
e.printStackTrace();
}
} else {
return data;
} }
}); }
t.start(); return out;
}
byte[] postProcessData(byte[] data) {
data = adjustGain(data);
if (effectEthereal) {
data = processEtherealEffect(data);
}
return data;
}
byte[] processEtherealEffect(byte[] data) {
AudioFormat format = getAudioFormat();
int frameSize = format.getFrameSize();
int channels = format.getChannels();
int bytesPerChannel = frameSize / channels;
int frames = data.length / frameSize;
int byteNo = 0;
double fpms = (double)format.getFrameRate() / 1000d;
double doubleOffset = fpms * (double) AudiobookRecorder.window.book.getInteger("effects.ethereal.offset");
int offset = (int)doubleOffset;
double attenuation = 1d - ((double)AudiobookRecorder.window.book.getInteger("effects.ethereal.attenuation") / 100d);
int copies = AudiobookRecorder.window.book.getInteger("effects.ethereal.iterations");
byte[] out = new byte[data.length];
for (int i = 0; i < frames; i++) {
if (channels == 1) {
int l = data[i * frameSize] >= 0 ? data[i * frameSize] : 256 + data[i * frameSize];
int h = data[(i * frameSize) + 1] >= 0 ? data[(i * frameSize) + 1] : 256 + data[(i * frameSize) + 1];
int sample = (h << 8) | l;
if ((sample & 0x8000) == 0x8000) sample |= 0xFFFF0000;
double sampleDouble = (double)sample;
int used = 0;
for (int j = 0; j < copies; j++) {
if (i + (j * offset) < frames) {
used++;
int lx = data[(i + (j * offset)) * frameSize] >= 0 ? data[(i + (j * offset)) * frameSize] : 256 + data[(i + (j * offset)) * frameSize];
int hx = data[((i + (j * offset)) * frameSize) + 1] >= 0 ? data[((i + (j * offset)) * frameSize) + 1] : 256 + data[((i + (j * offset)) * frameSize) + 1];
int futureSample = (hx << 8) | lx;
if ((futureSample & 0x8000) == 0x8000) futureSample |= 0xFFFF0000;
double futureDouble = (double)futureSample;
for (int k = 0; k < copies; k++) {
futureDouble *= attenuation;
}
sampleDouble = mix(sampleDouble, futureDouble);
}
}
sample = (int)sampleDouble;
if (sample > 32767) sample = 32767;
if (sample < -32768) sample = -32768;
out[i * frameSize] = (byte)(sample & 0xFF);
out[(i * frameSize) + 1] = (byte)((sample & 0xFF00) >> 8);
} else {
return data;
}
}
return out;
}
public void recognise() {
AudiobookRecorder.window.havenQueue.submit(Sentence.this);
} }
public void setLocked(boolean l) { public void setLocked(boolean l) {
@@ -658,7 +767,7 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
public void clearCache() { public void clearCache() {
storedAudioData = null; storedAudioData = null;
System.gc(); // System.gc();
} }
public boolean lockedInCache() { public boolean lockedInCache() {
@@ -730,4 +839,384 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
sentence.updateCrossings(); sentence.updateCrossings();
return sentence; return sentence;
} }
public void setAttentionFlag(boolean f) {
attention = f;
}
public boolean getAttentionFlag() {
return attention;
}
public String getHavenJobId() {
return havenJobId;
}
public void setHavenJobId(String i) {
havenJobId = i;
}
public int getHavenStatus() {
return havenStatus;
}
public void setHavenStatus(int i) {
havenStatus = i;
}
public boolean postHavenData() {
String apiKey = Options.get("process.haven.apikey");
if (apiKey == null || apiKey.equals("")) return false;
CloseableHttpClient httpclient = HttpClients.createDefault();
setOverrideText("[submitting...]");
AudiobookRecorder.window.bookTreeModel.reload(this);
try {
HttpPost httppost = new HttpPost("https://api.havenondemand.com/1/api/async/recognizespeech/v2?apikey=" + apiKey);
FileBody bin = new FileBody(getFile());
StringBody language = new StringBody("en-GB");
HttpEntity reqEntity = MultipartEntityBuilder.create()
.addPart("language_model", language)
.addPart("file", bin)
.build();
httppost.setEntity(reqEntity);
CloseableHttpResponse response = httpclient.execute(httppost);
try {
if (response.getStatusLine().getStatusCode() != 200) {
System.err.println("Error posting data: " + response.getStatusLine().getStatusCode());
return false;
}
HttpEntity resEntity = response.getEntity();
if (resEntity != null) {
JSONObject obj = new JSONObject(EntityUtils.toString(resEntity));
havenJobId = obj.getString("jobID");
System.err.println("Submitted new Haven OnDemand job #" + havenJobId);
havenStatus = 1;
}
EntityUtils.consume(resEntity);
} catch (Exception ex) {
ex.printStackTrace();
return false;
}
} catch (Exception ex) {
ex.printStackTrace();
return false;
}
return true;
// eddec91c-6018-4dcd-bd8d-5e96b23e334c --form "language_model=en-US" --form "file=@3e67460c-f298-4e2c-a412-d375d489e1b3.wav"
}
public void processPendingHaven() {
if (havenStatus != 1) return;
String apiKey = Options.get("process.haven.apikey");
if (apiKey == null || apiKey.equals("")) return;
CloseableHttpClient httpclient = HttpClients.createDefault();
try {
HttpPost httppost = new HttpPost("https://api.havenondemand.com/1/job/status/" + havenJobId + "?apikey=" + apiKey);
HttpEntity reqEntity = MultipartEntityBuilder.create().build();
httppost.setEntity(reqEntity);
CloseableHttpResponse response = httpclient.execute(httppost);
try {
if (response.getStatusLine().getStatusCode() != 200) {
havenStatus = 3;
return;
}
HttpEntity resEntity = response.getEntity();
if (resEntity != null) {
JSONObject obj = new JSONObject(EntityUtils.toString(resEntity));
System.err.println(havenJobId + ": " + obj.getString("status"));
if (obj.getString("status").equals("finished")) {
havenStatus = 2;
JSONArray textItems = obj.getJSONArray("actions").getJSONObject(0).getJSONObject("result").getJSONArray("items");
StringBuilder out = new StringBuilder();
for (int i = 0; i < textItems.length(); i++) {
out.append(textItems.getJSONObject(i).getString("text"));
out.append(" ");
}
String result = out.toString();
setText(result.trim());
AudiobookRecorder.window.bookTreeModel.reload(Sentence.this);
System.err.println(result);
} else if (obj.getString("status").equals("queued")) {
havenStatus = 1;
setOverrideText("[processing...]");
AudiobookRecorder.window.bookTreeModel.reload(Sentence.this);
} else {
text = id;
AudiobookRecorder.window.bookTreeModel.reload(Sentence.this);
havenStatus = 3;
return;
}
}
EntityUtils.consume(resEntity);
} catch (Exception ex) {
ex.printStackTrace();
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
public void setEthereal(boolean e) {
effectEthereal = e;
}
public boolean getEthereal() {
return effectEthereal;
}
public double mix(double a, double b) {
double z;
double fa, fb, fz;
fa = a + 32768d;
fb = b + 32768d;
if (fa < 32768d && fb < 32768d) {
fz = (fa * fb) / 32768d;
} else {
fz = (2d * (fa + fb)) - ((fa * fb) / 32768d) - 65536d;
}
z = fz - 32768d;
return z;
}
public int getPeakValue() {
int[] samples = getUnprocessedAudioData();
if (samples == null) {
return 0;
}
int ms = 0;
for (int i = 0; i < samples.length; i++) {
if (Math.abs(samples[i]) > ms) {
ms = Math.abs(samples[i]);
}
}
return ms;
}
public int getHeadroom() {
int nf = getPeakValue();
if (nf == 0) return 0;
double r = nf / 32767d;
double l10 = Math.log10(r);
double db = 20d * l10;
return (int)db;
}
public void setGain(double g) {
if (g <= 0.0001d) g = 1.0d;
if (g == gain) return;
gain = g;
clearCache();
}
public double getGain() {
return gain;
}
public void normalize() {
if (locked) return;
int max = getPeakValue();
double d = 23192d / max;
if (d > 1.1d) d = 1.1d;
setGain(d);
}
public int getEQProfile() {
return eqProfile;
}
public void setEQProfile(int e) {
eqProfile = e;
}
class ExternalEditor implements Runnable {
Sentence sentence;
ExternalEditor(Sentence s) {
sentence = s;
}
public void run() {
String command = Options.get("editor.external");
if (command == null) return;
if (command.equals("")) return;
String[] parts = command.split("::");
ArrayList<String> args = new ArrayList<String>();
for (String part : parts) {
if (part.equals("%f")) {
args.add(getFile().getAbsolutePath());
} else {
args.add(part);
}
}
try {
ProcessBuilder process = new ProcessBuilder(args);
Process proc = process.start();
proc.waitFor();
} catch (Exception e) {
}
clearCache();
AudiobookRecorder.window.updateWaveform();
}
}
public void openInExternalEditor() {
ExternalEditor ed = new ExternalEditor(this);
Thread t = new Thread(ed);
t.start();
}
public void backup() throws IOException {
File whereto = getFile().getParentFile();
String name = getFile().getName();
int backupNumber = -1;
for (int i = 1; i < 999999; i++) {
String fn = String.format("backup-%08d-%s", i, name);
File testFile = new File(whereto, fn);
if (!testFile.exists()) {
backupNumber = i;
break;
}
}
if (backupNumber == -1) {
System.err.println("Out of backup space!");
return;
}
String fn = String.format("backup-%08d-%s", backupNumber, getFile().getName());
File bak = new File(getFile().getParentFile(), fn);
Files.copy(getFile().toPath(), bak.toPath());
}
class ExternalProcessor implements Runnable {
Sentence sentence;
int number;
public ExternalProcessor(Sentence s, int num) {
sentence = s;
number = num;
}
public void run() {
String command = Options.get("editor.processor." + number + ".command");
if (command == null) return;
if (command.equals("")) return;
String[] parts = command.split("::");
ArrayList<String> args = new ArrayList<String>();
try {
backup();
} catch (Exception e) {
e.printStackTrace();
return;
}
File out = new File(getFile().getParentFile(), "proc-" + getFile().getName());
for (String part : parts) {
if (part.equals("%f")) {
args.add(getFile().getAbsolutePath());
} else if (part.equals("%o")) {
args.add(out.getAbsolutePath());
} else {
args.add(part);
}
}
try {
ProcessBuilder process = new ProcessBuilder(args);
Process proc = process.start();
proc.waitFor();
} catch (Exception e) {
}
if (out.exists()) {
try {
File in = getFile();
in.delete();
Files.copy(out.toPath(), in.toPath());
out.delete();
} catch (Exception e) {
e.printStackTrace();
}
}
clearCache();
AudiobookRecorder.window.updateWaveform();
}
}
public void runExternalProcessor(int num) {
if (isLocked()) return;
ExternalProcessor ed = new ExternalProcessor(this, num);
Thread t = new Thread(ed);
t.start();
}
public void undo() {
File whereto = getFile().getParentFile();
String name = getFile().getName();
int backupNumber = -1;
for (int i = 1; i < 999999; i++) {
String fn = String.format("backup-%08d-%s", i, name);
File testFile = new File(whereto, fn);
if (testFile.exists()) {
backupNumber = i;
} else {
break;
}
}
if (backupNumber == -1) {
return;
}
String fn = String.format("backup-%08d-%s", backupNumber, getFile().getName());
File bak = new File(getFile().getParentFile(), fn);
try {
File in = getFile();
in.delete();
Files.copy(bak.toPath(), in.toPath());
bak.delete();
} catch (Exception e) {
e.printStackTrace();
}
clearCache();
AudiobookRecorder.window.updateWaveform();
}
} }

View File

@@ -8,6 +8,7 @@ import java.awt.image.*;
import javax.swing.border.*; import javax.swing.border.*;
import java.util.*; import java.util.*;
import java.io.*; import java.io.*;
import java.net.*;
public class Utils { public class Utils {
public static Image getScaledImage(Image srcImg, int w, int h){ public static Image getScaledImage(Image srcImg, int w, int h){
@@ -46,4 +47,20 @@ public class Utils {
return 0.0f; return 0.0f;
} }
public static double s2d(String s) {
try {
return Double.parseDouble(s);
} catch (Exception e) {
}
return 0.0d;
}
public static void browse(String url) {
if (Desktop.isDesktopSupported()) {
try {
Desktop.getDesktop().browse(new URI(url));
} catch (Exception ex) {
}
}
}
} }

View File

@@ -105,12 +105,26 @@ public class Waveform extends JPanel implements MouseListener, MouseMotionListen
if (hcnt > 0) have /= hcnt; if (hcnt > 0) have /= hcnt;
if (lcnt > 0) lave /= lcnt; if (lcnt > 0) lave /= lcnt;
boolean clip = false;
if (lmax > 32000) { // -3dB == 23198?
clip = true;
}
if (hmax > 32000) { // -3dB
clip = true;
}
hmax /= scale; hmax /= scale;
lmax /= scale; lmax /= scale;
have /= scale; have /= scale;
lave /= scale; lave /= scale;
g.setColor(new Color(0, 20, 200)); if (clip) {
g.setColor(new Color(200, 20, 0));
} else {
g.setColor(new Color(0, 20, 200));
}
g.drawLine(n, h/2 + lmax, n, h/2 - hmax); g.drawLine(n, h/2 + lmax, n, h/2 - hmax);
g.setColor(new Color(0, 100, 255)); g.setColor(new Color(0, 100, 255));
g.drawLine(n, h/2 + (int)lave, n, h/2 - (int)have); g.drawLine(n, h/2 + (int)lave, n, h/2 - (int)have);