first commit

This commit is contained in:
2019-08-13 12:23:06 -05:00
commit 916073f43b
337 changed files with 23253 additions and 0 deletions

1
Lab 1/.idea/.name generated Normal file
View File

@@ -0,0 +1 @@
Lab1

18
Lab 1/.idea/checkstyle-idea.xml generated Normal file
View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CheckStyle-IDEA">
<option name="configuration">
<map>
<entry key="active-configuration" value="LOCAL_FILE:$PRJ_DIR$/SE1021_checkStyle - v3.xml:SE" />
<entry key="checkstyle-version" value="8.5" />
<entry key="copy-libs" value="true" />
<entry key="location-0" value="BUNDLED:(bundled):Sun Checks" />
<entry key="location-1" value="BUNDLED:(bundled):Google Checks" />
<entry key="location-2" value="LOCAL_FILE:$PRJ_DIR$/SE1021_checkStyle - v3.xml:SE" />
<entry key="scan-before-checkin" value="false" />
<entry key="scanscope" value="JavaOnly" />
<entry key="suppress-errors" value="false" />
</map>
</option>
</component>
</project>

View File

@@ -0,0 +1,6 @@
This folder contains libraries copied from the "Lab1" project.
It is managed by the CheckStyle-IDEA IDE plugin.
Do not modify this folder while the IDE is running.
When the IDE is stopped, you may delete this folder at any time. It will be recreated as needed.
In order to prevent the CheckStyle-IDEA IDE plugin from creating this folder,
uncheck the "Copy libraries from project directory" option in the CheckStyle-IDEA settings dialog.

6
Lab 1/.idea/misc.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

8
Lab 1/.idea/modules.xml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Lab1.iml" filepath="$PROJECT_DIR$/Lab1.iml" />
</modules>
</component>
</project>

124
Lab 1/.idea/uiDesigner.xml generated Normal file
View File

@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

559
Lab 1/.idea/workspace.xml generated Normal file
View File

@@ -0,0 +1,559 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="d369d029-8b7c-4b8a-8ba4-03a9baf4a391" name="Default" comment="" />
<ignored path="$PROJECT_DIR$/out/" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="CheckStyle-IDEA-workspace">
<option name="configuration">
<map>
<entry key="last-active-plugin-version" value="5.18.4" />
</map>
</option>
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="SE1021_checkStyle - v3.xml" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/SE1021_checkStyle - v3.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Lab1.java" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/barnestr/Lab1.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="357">
<caret line="21" column="19" lean-forward="false" selection-start-line="21" selection-start-column="19" selection-end-line="21" selection-end-column="19" />
<folding>
<element signature="e#0#4495#0" expanded="true" />
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="WavFile.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/edu/msoe/taylor/audio/WavFile.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1343">
<caret line="81" column="39" lean-forward="false" selection-start-line="81" selection-start-column="39" selection-end-line="81" selection-end-column="39" />
<folding>
<element signature="e#0#23440#0" expanded="true" />
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Class" />
</list>
</option>
</component>
<component name="GradleLocalSettings">
<option name="externalProjectsViewState">
<projects_view />
</option>
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/src/-WavFile.java.url" />
<option value="$PROJECT_DIR$/src/WavFile.java" />
<option value="$PROJECT_DIR$/src/edu/msoe/taylor/audio/WavFile.java" />
<option value="$PROJECT_DIR$/src/barnestr/Lab1.java" />
</list>
</option>
</component>
<component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
<component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
<component name="JsGulpfileManager">
<detection-done>true</detection-done>
<sorting>DEFINITION_ORDER</sorting>
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="953" />
<option name="width" value="974" />
<option name="height" value="1047" />
</component>
<component name="ProjectView">
<navigator currentView="ProjectPane" proportions="" version="1">
<flattenPackages />
<showMembers />
<showModules />
<showLibraryContents />
<hideEmptyPackages />
<abbreviatePackageNames />
<autoscrollToSource />
<autoscrollFromSource />
<sortByType />
<manualOrder />
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="PackagesPane" />
<pane id="Scratches" />
<pane id="AndroidView" />
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name="Lab1" type="b2602c69:ProjectViewProjectNode" />
<item name="Lab 1" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
</pane>
</panes>
</component>
<component name="PropertiesComponent">
<property name="settings.editor.selected.configurable" value="org.infernus.idea.checkstyle.CheckStyleConfigurable" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="project.structure.last.edited" value="Modules" />
<property name="project.structure.proportion" value="0.15" />
<property name="project.structure.side.proportion" value="0.2" />
</component>
<component name="RecentsManager">
<key name="CopyClassDialog.RECENTS_KEY">
<recent name="" />
</key>
<key name="MoveFile.RECENT_KEYS">
<recent name="C:\Users\barnestr\Documents\SE 1021\Spring 2018\Labs" />
<recent name="C:\Users\barnestr\Documents\SE 1021\Spring 2018\Labs\src" />
</key>
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager" selected="Application.Lab1">
<configuration name="Lab1" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea">
<pattern>
<option name="PATTERN" value="barnestr.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<option name="MAIN_CLASS_NAME" value="barnestr.Lab1" />
<option name="VM_PARAMETERS" />
<option name="PROGRAM_PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="ENABLE_SWING_INSPECTOR" value="false" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<module name="Lab1" />
<envs />
</configuration>
<configuration default="true" type="Applet" factoryName="Applet">
<module />
<option name="HTML_USED" value="false" />
<option name="WIDTH" value="400" />
<option name="HEIGHT" value="300" />
<option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
</configuration>
<configuration default="true" type="Application" factoryName="Application">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="MAIN_CLASS_NAME" />
<option name="VM_PARAMETERS" />
<option name="PROGRAM_PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="ENABLE_SWING_INSPECTOR" value="false" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<module name="" />
<envs />
</configuration>
<configuration default="true" type="JUnit" factoryName="JUnit">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="TEST_OBJECT" value="class" />
<option name="VM_PARAMETERS" value="-ea" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="singleModule" />
</option>
<envs />
<patterns />
</configuration>
<configuration default="true" type="#org.jetbrains.idea.devkit.run.PluginConfigurationType" factoryName="Plugin">
<module name="" />
<option name="VM_PARAMETERS" value="-Xmx512m -Xms256m -XX:MaxPermSize=250m -ea" />
<option name="PROGRAM_PARAMETERS" />
<predefined_log_file id="idea.log" enabled="true" />
</configuration>
<configuration default="true" type="Remote" factoryName="Remote">
<option name="USE_SOCKET_TRANSPORT" value="true" />
<option name="SERVER_MODE" value="false" />
<option name="SHMEM_ADDRESS" value="javadebug" />
<option name="HOST" value="localhost" />
<option name="PORT" value="5005" />
</configuration>
<configuration default="true" type="TestNG" factoryName="TestNG">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="SUITE_NAME" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="GROUP_NAME" />
<option name="TEST_OBJECT" value="CLASS" />
<option name="VM_PARAMETERS" value="-ea" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
<option name="OUTPUT_DIRECTORY" />
<option name="ANNOTATION_TYPE" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="singleModule" />
</option>
<option name="USE_DEFAULT_REPORTERS" value="false" />
<option name="PROPERTIES_FILE" />
<envs />
<properties />
<listeners />
</configuration>
<recent_temporary>
<list size="1">
<item index="0" class="java.lang.String" itemvalue="Application.Lab1" />
</list>
</recent_temporary>
</component>
<component name="ShelveChangesManager" show_recycled="false">
<option name="remove_strategy" value="false" />
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="d369d029-8b7c-4b8a-8ba4-03a9baf4a391" name="Default" comment="" />
<created>1520450498587</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1520450498587</updated>
<workItem from="1520450499939" duration="1129000" />
<workItem from="1520451693960" duration="203000" />
<workItem from="1520451946641" duration="10069000" />
<workItem from="1521051166427" duration="599000" />
<workItem from="1521052128944" duration="27000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="12027000" />
</component>
<component name="ToolWindowManager">
<frame x="-8" y="-8" width="1936" height="1056" extended-state="6" />
<editor active="true" />
<layout>
<window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Palette&#9;" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Image Layers" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Capture Analysis" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32979852" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="CheckStyle" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Capture Tool" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.12447917" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="UI Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Theme Preview" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32873806" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
</layout>
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager />
<watches-manager />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/SE1021_checkStyle - v3.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/edu/msoe/taylor/audio/WavFile.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1343">
<caret line="81" column="39" lean-forward="false" selection-start-line="81" selection-start-column="39" selection-end-line="81" selection-end-column="39" />
<folding>
<element signature="e#0#23440#0" expanded="true" />
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/barnestr/Lab1.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="357">
<caret line="21" column="19" lean-forward="false" selection-start-line="21" selection-start-column="19" selection-end-line="21" selection-end-column="19" />
<folding>
<element signature="e#0#4495#0" expanded="true" />
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/SE1021_checkStyle - v3.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/edu/msoe/taylor/audio/WavFile.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1122">
<caret line="81" column="39" lean-forward="true" selection-start-line="81" selection-start-column="39" selection-end-line="81" selection-end-column="39" />
<folding>
<element signature="e#0#23440#0" expanded="true" />
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/barnestr/Lab1.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="187">
<caret line="21" column="19" lean-forward="true" selection-start-line="21" selection-start-column="19" selection-end-line="21" selection-end-column="19" />
<folding>
<element signature="e#0#4495#0" expanded="true" />
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/SE1021_checkStyle - v3.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/edu/msoe/taylor/audio/WavFile.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="10064">
<caret line="617" column="1" lean-forward="false" selection-start-line="617" selection-start-column="1" selection-end-line="617" selection-end-column="1" />
<folding>
<element signature="e#0#23440#0" expanded="true" />
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/barnestr/Lab1.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="85">
<caret line="11" column="29" lean-forward="false" selection-start-line="11" selection-start-column="29" selection-end-line="11" selection-end-column="29" />
<folding>
<element signature="e#0#4495#0" expanded="true" />
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/SE1021_checkStyle - v3.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/edu/msoe/taylor/audio/WavFile.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="10064">
<caret line="617" column="1" lean-forward="false" selection-start-line="617" selection-start-column="1" selection-end-line="617" selection-end-column="1" />
<folding>
<element signature="e#0#23440#0" expanded="true" />
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/barnestr/Lab1.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="85">
<caret line="11" column="29" lean-forward="true" selection-start-line="11" selection-start-column="29" selection-end-line="11" selection-end-column="29" />
<folding>
<element signature="e#0#4495#0" expanded="true" />
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/SE1021_checkStyle - v3.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/-WavFile.java.url" />
<entry file="file://$PROJECT_DIR$/tone1.wav" />
<entry file="file://$PROJECT_DIR$/src/edu/msoe/taylor/audio/WavFile.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1343">
<caret line="81" column="39" lean-forward="false" selection-start-line="81" selection-start-column="39" selection-end-line="81" selection-end-column="39" />
<folding>
<element signature="e#0#23440#0" expanded="true" />
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tone2.wav" />
<entry file="file://$PROJECT_DIR$/src/barnestr/Lab1.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="357">
<caret line="21" column="19" lean-forward="false" selection-start-line="21" selection-start-column="19" selection-end-line="21" selection-end-column="19" />
<folding>
<element signature="e#0#4495#0" expanded="true" />
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
<component name="masterDetails">
<states>
<state key="ArtifactsStructureConfigurable.UI">
<settings>
<artifact-editor />
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="FacetStructureConfigurable.UI">
<settings>
<last-edited>No facets are configured</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="GlobalLibrariesConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="JdkListConfigurable.UI">
<settings>
<last-edited>1.8</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ModuleStructureConfigurable.UI">
<settings>
<last-edited>Lab1</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ProjectLibrariesConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>

11
Lab 1/Lab1.iml Normal file
View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@@ -0,0 +1,146 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
<!--
If you set the basedir property below, then all reported file
names will be relative to the specified directory. See
http://checkstyle.sourceforge.net/5.x/config.html#Checker
<property name="basedir" value="${basedir}"/>
-->
<property name="fileExtensions" value="java, properties, xml"/>
<!-- See http://checkstyle.sf.net/config_sizes.html -->
<module name="FileLength"/>
<!-- Checks for whitespace -->
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
<module name="FileTabCharacter"/>
<!-- Checks for Headers -->
<module name="RegexpHeader">
<property name="header" value= "/\*\n \* SE1021"/>
</module>
<module name="TreeWalker">
<!-- Checks for Javadoc comments. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
<module name="JavadocMethod">
<property name="minLineCount" value="1"/>
<property name="scope" value="public"/>
<property name="allowMissingPropertyJavadoc" value="true"/>
<property name="ignoreMethodNamesRegex" value="main"/>
<property name="allowedAnnotations" value=" "/>
</module>
<module name="JavadocType">
<property name="authorFormat" value="\S"/>
<property name="versionFormat" value="\S"/>
</module>
<module name="JavadocVariable">
<property name="scope" value="public"/>
</module>
<module name="JavadocStyle">
<property name="checkFirstSentence" value="false"/>
<property name="checkEmptyJavadoc" value="true"/>
</module>
<!-- Checks for Naming Conventions. -->
<!-- See http://checkstyle.sf.net/config_naming.html -->
<module name="ConstantName"/>
<module name="LocalVariableName"/>
<module name="MemberName"/>
<module name="MethodName"/>
<module name="ParameterName"/>
<module name="StaticVariableName"/>
<module name="TypeName"/>
<!-- Checks for imports -->
<!-- See http://checkstyle.sf.net/config_import.html -->
<module name="AvoidStarImport"/>
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
<module name="RedundantImport"/>
<module name="UnusedImports">
<property name="processJavadoc" value="false"/>
</module>
<!-- Checks for Size Violations. -->
<!-- See http://checkstyle.sf.net/config_sizes.html -->
<module name="LineLength">
<property name="max" value="120"/>
</module>
<module name="MethodLength"/>
<module name="ParameterNumber"/>
<!-- Checks for whitespace -->
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
<module name="GenericWhitespace"/>
<module name="MethodParamPad"/>
<module name="NoWhitespaceBefore"/>
<module name="ParenPad"/>
<!-- Modifier Checks -->
<!-- See http://checkstyle.sf.net/config_modifier.html -->
<module name="ModifierOrder"/>
<!-- Checks for blocks. You know, those {}'s -->
<!-- See http://checkstyle.sf.net/config_blocks.html -->
<module name="AvoidNestedBlocks"/>
<module name="EmptyBlock"/>
<module name="LeftCurly"/>
<module name="NeedBraces"/>
<module name="RightCurly"/>
<!-- Checks for common coding problems -->
<!-- See http://checkstyle.sf.net/config_coding.html -->
<module name="AvoidInlineConditionals"/>
<module name="EmptyStatement"/>
<module name="EqualsHashCode"/>
<module name="IllegalInstantiation"/>
<module name="InnerAssignment"/>
<module name="MagicNumber">
<property name="ignoreNumbers" value="-1, 0, 1, 2, 3, 4"/>
<property name="ignoreAnnotation" value="true"/>
</module>
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>
<!-- find incomplete autogenerated code -->
<module name="TodoComment">
<property name="format" value="(TODO)|(FIXME)|(Todo)|(to do)"/>
</module>
<module name="RegexpSinglelineJava">
<property name="format" value=" e\.printStackTrace\(\);"/>
<property name="ignoreComments" value="true"/>
</module>
<module name="RegexpSinglelineJava">
<property name="format" value="\* Created by [a-zA-Z 0-9]+ on [0-9]{1,2}/[0-9]{1,2}/[0-9]{4}\."/>
<property name="message" value="Autogenerated class comment"/>
</module>
<!-- Miscellaneous other checks. -->
<!-- See http://checkstyle.sf.net/config_misc.html -->
<module name="UpperEll"/>
<module name="MissingOverride"/>
<module name="IllegalCatch"/>
<module name="IllegalThrows"/>
<module name="OneTopLevelClass"/>
<module name="Indentation">
<property name="arrayInitIndent" value="8"/>
<property name="lineWrappingIndentation" value="8"/>
</module>
</module>
</module>

BIN
Lab 1/cymbal.wav Normal file

Binary file not shown.

BIN
Lab 1/ominous.wav Normal file

Binary file not shown.

Binary file not shown.

BIN
Lab 1/src/barnestr.zip Normal file

Binary file not shown.

View File

@@ -0,0 +1,123 @@
/*
* SE1021
* Spring 2017
* Lab 1 - WavFiles
* Name: Trevor Barnes
* Created: 3/7/18
*/
package barnestr;
import edu.msoe.taylor.audio.WavFile;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
/**
* Uses ArrayList to read and write .wav files.
*
* @author barnestr
* @version 1
*/
public class Lab1 {
static Scanner in = new Scanner(System.in);
static final int SAMPLE_RATE = 8000;
static final int VALID_BITS = 8;
static String option;
public static void main(String[] args) {
do {
String option = introOption();
if (option.equals("1")) {
fileReverser();
} else if (option.equals("2")) {
singleToneGenerator();
} else if (option.equals("3")) {
doubleToneGenerator();
} else {
System.exit(0);
}
} while (option.equals("1") || option.equals("2") || option.equals("3"));
}
/**
* Displays options for user
*
* @return option from user
*/
private static String introOption() {
System.out.println("Enter an option (0,1,2,3) to initiate.\n" +
"0. Exits Program\n" +
"1. Create a reversed version of a .wav file.\n" +
"2. Create a .wav file containing a one second tone at a given frequency.\n" +
"3. Create a .wav file containing a one second stereo sound with two tones given " +
"frequencies.\n");
option = in.nextLine();
while (!(option.equals("0") || option.equals("1") || option.equals("2") || option.equals("3"))) {
System.out.println("Please enter 0, 1, 2, or 3.");
option = in.nextLine();
}
return option;
}
/**
* Reverses given file
*/
public static void fileReverser() {
System.out.println("Enter a .wav filename (without .wav extension) with audio samples to be placed in " +
"reverse order.");
String filename = in.next(); //Receives original filename
WavFile original = new WavFile(filename + ".wav"); //Creates WavFile with original filename
ArrayList<Double> samples = new ArrayList<>();
samples.addAll(original.getSamples());
Collections.reverse(samples);
WavFile file = new WavFile(filename + "Rev.wav", original.getNumChannels(), original.getNumFrames(),
original.getValidBits(), original.getSampleRate());
file.setSamples(samples);
file.close();
System.out.println("File reversed with name " + filename + "Rev.wav \n");
}
/**
* Generates a .wav file with a one second tone
*/
public static void singleToneGenerator() {
System.out.println("Enter a .wav filename (without .wav extension) to be created.");
String filename = in.next();
System.out.println("Enter the frequency of tone to be created.");
double frequency = in.nextDouble();
ArrayList<Double> samples = new ArrayList();
for (int i = 0; i < SAMPLE_RATE; i++) {
samples.add(Math.sin(2 * Math.PI * i * (frequency / SAMPLE_RATE)));
}
WavFile file = new WavFile(filename + ".wav", 1, SAMPLE_RATE, VALID_BITS, SAMPLE_RATE);
file.setSamples(samples);
file.close();
System.out.println("File with generated single tone created as " + filename + ".wav \n");
}
/**
* Generates a .wav file with two one second tones in stereo
*/
public static void doubleToneGenerator() {
System.out.println("Enter a .wav filename (without .wav extension) of stereo file to be created.");
String filename = in.next();
System.out.println("Enter the first frequency of tone to be created.");
int frequency1 = in.nextInt();
System.out.println("Enter the second frequency of tone to be created.");
int frequency2 = in.nextInt();
ArrayList samples = new ArrayList();
for (int i = 0; i < SAMPLE_RATE; i = i + 2) {
samples.add(Math.sin(2 * Math.PI * i * (frequency1 / SAMPLE_RATE)));
}
for (int i = 1; i < SAMPLE_RATE; i = i + 2) {
samples.add(Math.sin(2 * Math.PI * i * (frequency2 / SAMPLE_RATE)));
}
WavFile file = new WavFile(filename + ".wav", 2, SAMPLE_RATE, VALID_BITS, SAMPLE_RATE);
file.setSamples(samples);
file.close();
}
}

View File

@@ -0,0 +1,618 @@
/*
* Developed for SE1021
* Winter 2017-2018
* Lab 1
* Name: Dr. Chris Taylor
* Created: 11/21/2017
*/
// You must not change the following package declaration.
// Instead, you must place this file in the appropriate folder.
package edu.msoe.taylor.audio;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
/**
* A simple class for reading, writing, and accessing audio samples
* associated with a .wav file.
*
* The class is based on a similar class developed by A. Greensted.
* http://www.labbookpages.co.uk/audio/javaWavFiles.html
* <p>
* The file format is based on information from:
* http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html
* http://www.blitter.com/~russtopia/MIDI/~jglatt/tech/wave.htm
* </p>
* @author edu.msoe@taylor and A.Greensted
* @version 20171121.5
*/
public class WavFile {
private enum IOState {READING, WRITING, CLOSED}
private final static int BUFFER_SIZE = 4096;
private final static int FMT_CHUNK_ID = 0x20746D66;
private final static int DATA_CHUNK_ID = 0x61746164;
private final static int RIFF_CHUNK_ID = 0x46464952;
private final static int RIFF_TYPE_ID = 0x45564157;
private File file; // File that will be read from or written to
private IOState ioState; // Specifies the IO State of the Wav File (used for sanity
// checking)
private int bytesPerSample; // Number of bytes required to store a single sample
private long numFrames; // Number of frames within the data section
private FileOutputStream oStream; // Output stream used for writing data
private FileInputStream iStream; // Input stream used for reading data
private double floatScale; // Scaling factor used for int <-> float conversion
private double floatOffset; // Offset factor used for int <-> float conversion
private boolean wordAlignAdjust; // Specify if an extra byte at the end of the data chunk is
// required for word alignment
// Wav Header
private int numChannels; // 2 bytes unsigned, 0x0001 (1) to 0xFFFF (65,535)
private long sampleRate; // 4 bytes unsigned, 0x00000001 (1) to 0xFFFFFFFF
// (4,294,967,295)
// Although a java int is 4 bytes, it is signed, so need to
// use a long
private int blockAlign; // 2 bytes unsigned, 0x0001 (1) to 0xFFFF (65,535)
private int validBits; // 2 bytes unsigned, 0x0002 (2) to 0xFFFF (65,535)
// Buffering
private byte[] innerBuffer; // Local innerBuffer used for IO
private int bufferPointer; // Points to the current position in innerBuffer
private int bytesRead; // Bytes read after last read into innerBuffer
private long frameCounter; // Current number of frames read or written
/**
* This constructor should not be called directly.
*/
private WavFile() {
innerBuffer = new byte[BUFFER_SIZE];
}
/**
* Constructor for creating a WavFile object to be read from a file.
* @param filename The filename of the file to be read into this object
*/
public WavFile(String filename) {
this();
this.file = new File(filename);
try {
// Create a new file input stream for reading file data
iStream = new FileInputStream(file);
// Read the first 12 bytes of the file
int bytesRead = iStream.read(innerBuffer, 0, 12);
if(bytesRead!=12) {
throw new RuntimeException("Not enough wav file bytes for header");
}
} catch (IOException e) {
throw new RuntimeException("Encountered and error reading: " + e.getMessage());
}
// Extract parts from the header
long riffChunkID = getLE(innerBuffer, 0, 4);
long chunkSize = getLE(innerBuffer, 4, 4);
long riffTypeID = getLE(innerBuffer, 8, 4);
// Check the header bytes contains the correct signature
if(riffChunkID!=RIFF_CHUNK_ID) {
throw new RuntimeException("Invalid Wav Header data, incorrect riff chunk ID");
}
if(riffTypeID!=RIFF_TYPE_ID) {
throw new RuntimeException("Invalid Wav Header data, incorrect riff type ID");
}
// Check that the file size matches the number of bytes listed in header
if(this.file.length()!=chunkSize+8) {
throw new RuntimeException("Header chunk size (" + chunkSize +
") does not match file size (" + this.file.length() + ")");
}
boolean foundFormat = false;
boolean foundData = false;
// Search for the Format and Data Chunks
while(!foundData) {
// Read the first 8 bytes of the chunk (ID and chunk size)
try {
bytesRead = iStream.read(innerBuffer, 0, 8);
} catch (IOException e) {
throw new RuntimeException("Encountered and error reading: " + e.getMessage());
}
if(bytesRead==-1) {
throw new RuntimeException("Reached end of file without finding format chunk");
}
if(bytesRead!=8) {
throw new RuntimeException("Could not read chunk header");
}
// Extract the chunk ID and Size
long chunkID = getLE(innerBuffer, 0, 4);
chunkSize = getLE(innerBuffer, 4, 4);
// Word align the chunk size
// chunkSize specifies the number of bytes holding data. However,
// the data should be word aligned (2 bytes) so we need to calculate
// the actual number of bytes in the chunk
long numChunkBytes = (chunkSize%2 == 1) ? chunkSize+1 : chunkSize;
if(chunkID==FMT_CHUNK_ID) {
// Flag that the format chunk has been found
foundFormat = true;
// Read in the header info
try {
iStream.read(innerBuffer, 0, 16);
} catch (IOException e) {
throw new RuntimeException("Encountered and error reading: " + e.getMessage());
}
// Check this is uncompressed data
int compressionCode = (int)getLE(innerBuffer, 0, 2);
if(compressionCode!=1) {
throw new RuntimeException("Compression Code " + compressionCode +
" not supported");
}
// Extract the format information
numChannels = (int)getLE(innerBuffer, 2, 2);
sampleRate = getLE(innerBuffer, 4, 4);
blockAlign = (int)getLE(innerBuffer, 12, 2);
validBits = (int)getLE(innerBuffer, 14, 2);
if(numChannels==0) {
throw new RuntimeException("Number of channels specified in header is " +
"equal to zero");
}
if(blockAlign==0) {
throw new RuntimeException("Block Align specified in header is equal to zero");
}
if(validBits<2) {
throw new RuntimeException("Valid Bits specified in header is less than 2");
}
if(validBits>64) {
throw new RuntimeException("Valid Bits specified in header is greater than " +
"64, this is greater than a long can hold");
}
// Calculate the number of bytes required to hold 1 sample
bytesPerSample = (validBits + 7) / 8;
if(bytesPerSample*numChannels!=blockAlign) {
throw new RuntimeException("Block Align does not agree with bytes required " +
"for validBits and number of channels");
}
// Account for number of format bytes and then skip over
// any extra format bytes
numChunkBytes -= 16;
if(numChunkBytes>0) {
try {
iStream.skip(numChunkBytes);
} catch (IOException e) {
throw new RuntimeException("Encountered and error reading: " +
e.getMessage());
}
}
} else if(chunkID==DATA_CHUNK_ID) {
// Check if we've found the format chunk,
// If not, throw an exception as we need the format information
// before we can read the data chunk
if(!foundFormat) {
throw new RuntimeException("Data chunk found before Format chunk");
}
// Check that the chunkSize (wav data length) is a multiple of the
// block align (bytes per frame)
if(chunkSize%blockAlign!=0) {
throw new RuntimeException("Data Chunk size is not multiple of Block Align");
}
// Calculate the number of frames
numFrames = chunkSize / blockAlign;
// Flag that we've found the wave data chunk
foundData = true;
} else {
// If an unknown chunk ID is found, just skip over the chunk data
try {
iStream.skip(numChunkBytes);
} catch (IOException e) {
throw new RuntimeException("Encountered and error reading: " + e.getMessage());
}
}
}
// Throw an exception if no data chunk has been found
if(!foundData) {
throw new RuntimeException("Did not find a data chunk");
}
// Calculate the scaling factor for converting to a normalised double
if(validBits>8) {
// If more than 8 validBits, data is signed
// Conversion required dividing by magnitude of max negative value
floatOffset = 0;
floatScale = 1 << (validBits - 1);
} else {
// Else if 8 or less validBits, data is unsigned
// Conversion required dividing by max positive value
floatOffset = -1;
floatScale = 0.5 * ((1 << validBits) - 1);
}
bufferPointer = 0;
this.bytesRead = 0;
frameCounter = 0;
ioState = IOState.READING;
}
/**
* Constructor for creating a WavFile object to be written to a file.
* @param filename The filename of the file this object should be written to
* @param numChannels The number of channels of audio
* @param numFrames The number of frames of audio
* @param validBits The number of valid bits
* @param sampleRate The sample rate for the audio samples
*/
public WavFile(String filename, int numChannels, long numFrames, int validBits,
long sampleRate) {
this();
this.file = new File(filename);
this.numChannels = numChannels;
this.numFrames = numFrames;
this.sampleRate = sampleRate;
bytesPerSample = (validBits + 7) / 8;
blockAlign = this.bytesPerSample * numChannels;
this.validBits = validBits;
// Sanity check arguments
if(numChannels<1 || numChannels>65535) {
throw new RuntimeException("Illegal number of channels, valid range 1 to 65536");
}
if(numFrames<0) {
throw new RuntimeException("Number of frames must be positive");
}
if(validBits<2 || validBits>65535) {
throw new RuntimeException("Illegal number of valid bits, valid range 2 to 65536");
}
if(sampleRate<0) {
throw new RuntimeException("Sample rate must be positive");
}
try {
// Create output stream for writing data
oStream = new FileOutputStream(file);
// Calculate the chunk sizes
long dataChunkSize = blockAlign * numFrames;
long mainChunkSize = 4 + // Riff Type
8 + // Format ID and size
16 + // Format data
8 + // Data ID and size
dataChunkSize;
// Chunks must be word aligned, so if odd number of audio data bytes
// adjust the main chunk size
if (dataChunkSize % 2 == 1) {
mainChunkSize += 1;
wordAlignAdjust = true;
} else {
wordAlignAdjust = false;
}
// Set the main chunk size
putLE(RIFF_CHUNK_ID, innerBuffer, 0, 4);
putLE(mainChunkSize, innerBuffer, 4, 4);
putLE(RIFF_TYPE_ID, innerBuffer, 8, 4);
// Write out the header
oStream.write(innerBuffer, 0, 12);
// Put format data in innerBuffer
long averageBytesPerSecond = sampleRate * blockAlign;
putLE(FMT_CHUNK_ID, innerBuffer, 0, 4); // Chunk ID
putLE(16, innerBuffer, 4, 4); // Chunk Data Size
putLE(1, innerBuffer, 8, 2); // Compression Code (Uncompressed)
putLE(numChannels, innerBuffer, 10, 2); // Number of channels
putLE(sampleRate, innerBuffer, 12, 4); // Sample Rate
putLE(averageBytesPerSecond, innerBuffer, 16, 4); // Average Bytes Per Second
putLE(blockAlign, innerBuffer, 20, 2); // Block Align
putLE(validBits, innerBuffer, 22, 2); // Valid Bits
// Write Format Chunk
oStream.write(innerBuffer, 0, 24);
// Start Data Chunk
putLE(DATA_CHUNK_ID, innerBuffer, 0, 4); // Chunk ID
putLE(dataChunkSize, innerBuffer, 4, 4); // Chunk Data Size
// Write Format Chunk
oStream.write(innerBuffer, 0, 8);
} catch (IOException e) {
throw new RuntimeException("Problems with IO: " + e.getMessage());
}
// Calculate the scaling factor for converting to a normalised double
if(this.validBits>8) {
// If more than 8 validBits, data is signed
// Conversion required multiplying by magnitude of max positive value
floatOffset = 0;
floatScale = Long.MAX_VALUE >> (64 - this.validBits);
} else {
// Else if 8 or less validBits, data is unsigned
// Conversion required dividing by max positive value
floatOffset = 1;
floatScale = 0.5 * ((1 << this.validBits) - 1);
}
// Finally, set the IO State
bufferPointer = 0;
bytesRead = 0;
frameCounter = 0;
ioState = IOState.WRITING;
}
public int getNumChannels() {
return numChannels;
}
public long getNumFrames() {
return numFrames;
}
public long getSampleRate() {
return sampleRate;
}
public int getValidBits() {
return validBits;
}
/**
* Gets all of the audio samples for the wav file
* <p>This method should only be called once.</p>
* <p>Returns null if an IO exception was encountered.</p>
* @return All of the audio samples for the wav file or null (if an IOException was thrown)
*/
public ArrayList<Double> getSamples() {
ArrayList<Double> samples = new ArrayList<>();
try {
double[][] buffer = new double[numChannels][BUFFER_SIZE];
int framesRead = 0;
do {
framesRead = readFrames(buffer, BUFFER_SIZE);
for (int frame=0; frame<framesRead; ++frame) {
for (int channel=0; channel<numChannels; ++channel) {
samples.add(buffer[channel][frame]);
}
}
} while (framesRead!=0);
} catch (IOException e) {
samples = null;
}
return samples;
}
/**
* Writes the audio samples passed to the wav file
* <p>This method should only be called once.</p>
* @param samples The audio samples for the wav file
* @return returns true if successful, false if not (IOException was encountered)
*/
public boolean setSamples(ArrayList<Double> samples) {
double[] buffer = new double[samples.size()];
for(int i=0; i<buffer.length; ++i) {
buffer[i] = samples.get(i);
}
boolean successful = true;
try{
writeFrames(buffer, samples.size()/numChannels);
} catch (IOException e) {
successful = false;
}
return successful;
}
/**
* Frees up resources associated with the object and releases
* the file associated with the object
* @return returns true if successful, false if not (IOException was encountered)
*/
public boolean close() {
boolean successful = true;
// Close the input stream and set to null
if(iStream!=null) {
try {
iStream.close();
} catch (IOException e) {
successful = false;
}
iStream = null;
}
if(oStream!=null) {
try {
// Write out anything still in the innerBuffer
if (bufferPointer > 0) {
oStream.write(innerBuffer, 0, bufferPointer);
}
// If an extra byte is required for word alignment, add it to the end
if (wordAlignAdjust) {
oStream.write(0);
}
} catch (IOException e) {
successful = false;
}
try {
oStream.close();
} catch (IOException e) {
successful = false;
}
oStream = null;
}
ioState = IOState.CLOSED;
return successful;
}
@Override
public String toString() {
return "File: " + file
+ "\nChannels: " + numChannels + ", Frames: " + numFrames
+ "\nIO State: " + ioState
+ "\nSample Rate: " + sampleRate + ", Block Align: " + blockAlign
+ "\nValid Bits: " + validBits + ", Bytes per sample: " + bytesPerSample;
}
// Get and Put little endian data from innerBuffer
// ------------------------------------------------
/**
* Get little endian data from the innerBuffer
* @param buffer The buffer with little endian data
* @param position Position in the buffer
* @param numBytes Number of bytes to be converted to a long
* @return The little endian representation of data from the buffer
*/
private static long getLE(byte[] buffer, int position, int numBytes) {
--numBytes;
position += numBytes;
long value = buffer[position] & 0xFF;
for(int b=0; b<numBytes; b++) {
value = (value << 8) + (buffer[--position] & 0xFF);
}
return value;
}
/**
* Put the little endian data into the buffer
* @param value Value to be placed into the buffer
* @param buffer The buffer with the little endian data
* @param position Position in the buffer
* @param numBytes Number of bytes to be converted from the long
*/
private static void putLE(long value, byte[] buffer, int position, int numBytes) {
for(int b=0; b<numBytes; b++) {
buffer[position] = (byte)(value & 0xFF);
value >>= 8;
++position;
}
}
/**
* Get the number of frames left to read or write.
* @return The number of frames that have not been processed
*/
private long getFramesRemaining() {
return numFrames - frameCounter;
}
/**
* Read audio data from the wav file.
* @param sampleBuffer Buffer to hold sample data
* @param numFramesToRead Maximum number of frames to read
* @return The number of frames actually read
* @throws IOException Thrown if an input error is encountered
*/
private int readFrames(double[][] sampleBuffer, int numFramesToRead) throws IOException {
if(ioState != IOState.READING) {
throw new IOException("Cannot read from WavFile instance");
}
int offset = 0;
numFramesToRead = (int)Math.min(numFramesToRead, getFramesRemaining());
for(int frame=0; frame<numFramesToRead; ++frame) {
for(int channel=0; channel<numChannels; ++channel) {
sampleBuffer[channel][offset] = floatOffset + (double)readSample() / floatScale;
}
++offset;
++frameCounter;
}
return numFramesToRead;
}
/**
* Reads one audio sample from the wav file.
* @return The value of the audio sample
* @throws IOException Thrown if an input error is encountered
*/
private long readSample() throws IOException {
long value = 0;
for(int b=0; b<bytesPerSample; b++) {
if(bufferPointer == bytesRead) {
int read = iStream.read(innerBuffer, 0, BUFFER_SIZE);
if(read == -1) {
throw new RuntimeException("Not enough data available");
}
bytesRead = read;
bufferPointer = 0;
}
int val = innerBuffer[bufferPointer];
if(b<bytesPerSample-1 || bytesPerSample==1) {
val &= 0xFF;
}
value += val << (b * 8);
bufferPointer++;
}
return value;
}
/**
* Write audio data to the wav file.
* @param sampleBuffer Samples to be written to the file
* @param numFramesToWrite Maximum number of frames to write
* @return The number of frames actually written
* @throws IOException Thrown if an output error is encountered
*/
private int writeFrames(double[] sampleBuffer, int numFramesToWrite) throws IOException {
if(ioState != IOState.WRITING) {
throw new IOException("Cannot write to WavFile instance");
}
int offset = 0;
numFramesToWrite = (int)Math.min(numFramesToWrite, getFramesRemaining());
for(int frame=0; frame<numFramesToWrite; ++frame) {
for(int channel=0; channel<numChannels; ++channel) {
writeSample((long)(floatScale * (floatOffset + sampleBuffer[offset])));
++offset;
}
++frameCounter;
}
return numFramesToWrite;
}
/**
* Writes one audio sample to the wav file.
* @param value The value of the audio sample
* @throws IOException Thrown if an output error is encountered
*/
private void writeSample(long value) throws IOException {
for(int b=0; b<bytesPerSample; b++) {
if(bufferPointer==BUFFER_SIZE) {
oStream.write(innerBuffer, 0, BUFFER_SIZE);
bufferPointer = 0;
}
innerBuffer[bufferPointer] = (byte)(value & 0xFF);
value >>= 8;
++bufferPointer;
}
}
}