New sample: AudioStation implements a simple JavaSound-based editor for WAV files, and
demonstrates the use of Lookup to plug different visualizations into a multiview editor.
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/platform/samples/AudioStation/branding/core/core.jar/org/netbeans/core/startup/Bundle.properties Thu Nov 02 01:01:27 2006 +0000
1.3 @@ -0,0 +1,7 @@
1.4 +currentVersion=AudioStation {0}
1.5 +SPLASH_HEIGHT=450
1.6 +SPLASH_WIDTH=600
1.7 +SplashProgressBarBounds=2,412,598,6
1.8 +SplashProgressBarColor=0x508996
1.9 +SplashRunningTextBounds=11,393,260,15
1.10 +SplashRunningTextFontSize=16
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/platform/samples/AudioStation/branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties Thu Nov 02 01:01:27 2006 +0000
2.3 @@ -0,0 +1,2 @@
2.4 +CTL_MainWindow_Title=AudioStation {0}
2.5 +CTL_MainWindow_Title_No_Project=AudioStation {0}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/platform/samples/AudioStation/branding/modules/org-netbeans-core.jar/org/netbeans/core/ui/Bundle.properties Thu Nov 02 01:01:27 2006 +0000
3.3 @@ -0,0 +1,1 @@
3.4 +LBL_ProductInformation=AudioStation
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/platform/samples/AudioStation/build.xml Thu Nov 02 01:01:27 2006 +0000
4.3 @@ -0,0 +1,8 @@
4.4 +<?xml version="1.0" encoding="UTF-8"?>
4.5 +<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
4.6 +<!-- for some information on what you could do (e.g. targets to override). -->
4.7 +<!-- If you delete this file and reopen the project it will be recreated. -->
4.8 +<project name="AudioStation" basedir=".">
4.9 + <description>Builds the module suite AudioStation.</description>
4.10 + <import file="nbproject/build-impl.xml"/>
4.11 +</project>
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/platform/samples/AudioStation/fftview/build.xml Thu Nov 02 01:01:27 2006 +0000
5.3 @@ -0,0 +1,8 @@
5.4 +<?xml version="1.0" encoding="UTF-8"?>
5.5 +<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
5.6 +<!-- for some information on what you could do (e.g. targets to override). -->
5.7 +<!-- If you delete this file and reopen the project it will be recreated. -->
5.8 +<project name="org.foo.fftview" default="netbeans" basedir=".">
5.9 + <description>Builds, tests, and runs the project org.foo.fftview.</description>
5.10 + <import file="nbproject/build-impl.xml"/>
5.11 +</project>
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/platform/samples/AudioStation/fftview/manifest.mf Thu Nov 02 01:01:27 2006 +0000
6.3 @@ -0,0 +1,6 @@
6.4 +Manifest-Version: 1.0
6.5 +OpenIDE-Module: org.foo.fftview
6.6 +OpenIDE-Module-Layer: org/foo/fftview/layer.xml
6.7 +OpenIDE-Module-Localizing-Bundle: org/foo/fftview/Bundle.properties
6.8 +OpenIDE-Module-Specification-Version: 1.0
6.9 +
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/platform/samples/AudioStation/fftview/nbproject/build-impl.xml Thu Nov 02 01:01:27 2006 +0000
7.3 @@ -0,0 +1,30 @@
7.4 +<?xml version="1.0" encoding="UTF-8"?>
7.5 +<!--
7.6 +*** GENERATED FROM project.xml - DO NOT EDIT ***
7.7 +*** EDIT ../build.xml INSTEAD ***
7.8 +-->
7.9 +<project name="org.foo.fftview-impl" basedir=".." xmlns:nbmproject="http://www.netbeans.org/ns/nb-module-project/2">
7.10 + <property file="nbproject/private/suite-private.properties"/>
7.11 + <property file="nbproject/suite.properties"/>
7.12 + <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
7.13 + <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
7.14 + <property file="${suite.dir}/nbproject/platform.properties"/>
7.15 + <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
7.16 + <attribute name="name"/>
7.17 + <attribute name="value"/>
7.18 + <sequential>
7.19 + <property name="@{name}" value="${@{value}}"/>
7.20 + </sequential>
7.21 + </macrodef>
7.22 + <property file="${user.properties.file}"/>
7.23 + <nbmproject:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir"/>
7.24 + <nbmproject:property name="netbeans.dest.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir"/>
7.25 + <fail message="You must define 'nbplatform.${nbplatform.active}.harness.dir'">
7.26 + <condition>
7.27 + <not>
7.28 + <available file="${harness.dir}" type="dir"/>
7.29 + </not>
7.30 + </condition>
7.31 + </fail>
7.32 + <import file="${harness.dir}/build.xml"/>
7.33 +</project>
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/platform/samples/AudioStation/fftview/nbproject/genfiles.properties Thu Nov 02 01:01:27 2006 +0000
8.3 @@ -0,0 +1,8 @@
8.4 +build.xml.data.CRC32=6be87094
8.5 +build.xml.script.CRC32=f31a48da
8.6 +build.xml.stylesheet.CRC32=77ef55dd
8.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
8.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
8.9 +nbproject/build-impl.xml.data.CRC32=6be87094
8.10 +nbproject/build-impl.xml.script.CRC32=96fa18cf
8.11 +nbproject/build-impl.xml.stylesheet.CRC32=2607fe5f
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2 +++ b/platform/samples/AudioStation/fftview/nbproject/platform.properties Thu Nov 02 01:01:27 2006 +0000
9.3 @@ -0,0 +1,132 @@
9.4 +# Deprecated since 5.0u1; for compatibility with 5.0:
9.5 +disabled.clusters=\
9.6 + enterprise3,\
9.7 + harness,\
9.8 + nb5.5
9.9 +disabled.modules=\
9.10 + javax.jmi.model,\
9.11 + javax.jmi.reflect,\
9.12 + org.apache.tools.ant.module,\
9.13 + org.apache.xml.resolver,\
9.14 + org.netbeans.api.debugger,\
9.15 + org.netbeans.api.debugger.jpda,\
9.16 + org.netbeans.api.java,\
9.17 + org.netbeans.api.mdr,\
9.18 + org.netbeans.api.xml,\
9.19 + org.netbeans.core.ide,\
9.20 + org.netbeans.jmi.javamodel,\
9.21 + org.netbeans.lib.cvsclient,\
9.22 + org.netbeans.libs.commons_logging,\
9.23 + org.netbeans.libs.formlayout,\
9.24 + org.netbeans.libs.jsch,\
9.25 + org.netbeans.libs.xerces,\
9.26 + org.netbeans.modules.ant.browsetask,\
9.27 + org.netbeans.modules.ant.debugger,\
9.28 + org.netbeans.modules.ant.freeform,\
9.29 + org.netbeans.modules.ant.grammar,\
9.30 + org.netbeans.modules.apisupport.ant,\
9.31 + org.netbeans.modules.apisupport.feedreader,\
9.32 + org.netbeans.modules.apisupport.paintapp,\
9.33 + org.netbeans.modules.apisupport.project,\
9.34 + org.netbeans.modules.apisupport.refactoring,\
9.35 + org.netbeans.modules.beans,\
9.36 + org.netbeans.modules.classfile,\
9.37 + org.netbeans.modules.clazz,\
9.38 + org.netbeans.modules.css,\
9.39 + org.netbeans.modules.db,\
9.40 + org.netbeans.modules.db.core,\
9.41 + org.netbeans.modules.db.sql.editor,\
9.42 + org.netbeans.modules.dbapi,\
9.43 + org.netbeans.modules.debugger.jpda,\
9.44 + org.netbeans.modules.debugger.jpda.ant,\
9.45 + org.netbeans.modules.debugger.jpda.ui,\
9.46 + org.netbeans.modules.defaults,\
9.47 + org.netbeans.modules.diff,\
9.48 + org.netbeans.modules.editor,\
9.49 + org.netbeans.modules.editor.bookmarks,\
9.50 + org.netbeans.modules.editor.codetemplates,\
9.51 + org.netbeans.modules.editor.completion,\
9.52 + org.netbeans.modules.editor.errorstripe,\
9.53 + org.netbeans.modules.editor.errorstripe.api,\
9.54 + org.netbeans.modules.editor.hints,\
9.55 + org.netbeans.modules.editor.plain,\
9.56 + org.netbeans.modules.editor.plain.lib,\
9.57 + org.netbeans.modules.editor.settings,\
9.58 + org.netbeans.modules.editor.settings.storage,\
9.59 + org.netbeans.modules.editor.structure,\
9.60 + org.netbeans.modules.extbrowser,\
9.61 + org.netbeans.modules.form,\
9.62 + org.netbeans.modules.html,\
9.63 + org.netbeans.modules.html.editor,\
9.64 + org.netbeans.modules.html.editor.lib,\
9.65 + org.netbeans.modules.httpserver,\
9.66 + org.netbeans.modules.i18n,\
9.67 + org.netbeans.modules.i18n.form,\
9.68 + org.netbeans.modules.image,\
9.69 + org.netbeans.modules.j2ee.metadata,\
9.70 + org.netbeans.modules.j2ee.persistenceapi,\
9.71 + org.netbeans.modules.java,\
9.72 + org.netbeans.modules.java.editor,\
9.73 + org.netbeans.modules.java.editor.lib,\
9.74 + org.netbeans.modules.java.examples,\
9.75 + org.netbeans.modules.java.freeform,\
9.76 + org.netbeans.modules.java.hints,\
9.77 + org.netbeans.modules.java.j2seplatform,\
9.78 + org.netbeans.modules.java.j2seproject,\
9.79 + org.netbeans.modules.java.navigation,\
9.80 + org.netbeans.modules.java.platform,\
9.81 + org.netbeans.modules.java.project,\
9.82 + org.netbeans.modules.javacore,\
9.83 + org.netbeans.modules.javadoc,\
9.84 + org.netbeans.modules.jmiutils,\
9.85 + org.netbeans.modules.junit,\
9.86 + org.netbeans.modules.mdr,\
9.87 + org.netbeans.modules.options.api,\
9.88 + org.netbeans.modules.options.editor,\
9.89 + org.netbeans.modules.project.ant,\
9.90 + org.netbeans.modules.project.libraries,\
9.91 + org.netbeans.modules.projectapi,\
9.92 + org.netbeans.modules.projectui,\
9.93 + org.netbeans.modules.projectuiapi,\
9.94 + org.netbeans.modules.properties,\
9.95 + org.netbeans.modules.properties.syntax,\
9.96 + org.netbeans.modules.refactoring,\
9.97 + org.netbeans.modules.schema2beans,\
9.98 + org.netbeans.modules.servletapi,\
9.99 + org.netbeans.modules.suggestions_framework,\
9.100 + org.netbeans.modules.tasklist.core,\
9.101 + org.netbeans.modules.tasklist.docscan,\
9.102 + org.netbeans.modules.usersguide,\
9.103 + org.netbeans.modules.utilities,\
9.104 + org.netbeans.modules.utilities.project,\
9.105 + org.netbeans.modules.versioning,\
9.106 + org.netbeans.modules.versioning.system.cvss,\
9.107 + org.netbeans.modules.websvc.clientapi,\
9.108 + org.netbeans.modules.websvc.jaxrpc16,\
9.109 + org.netbeans.modules.websvc.jaxws20,\
9.110 + org.netbeans.modules.websvc.jaxwsapi,\
9.111 + org.netbeans.modules.websvc.jaxwsmodel,\
9.112 + org.netbeans.modules.xml.catalog,\
9.113 + org.netbeans.modules.xml.core,\
9.114 + org.netbeans.modules.xml.multiview,\
9.115 + org.netbeans.modules.xml.retriever,\
9.116 + org.netbeans.modules.xml.schema,\
9.117 + org.netbeans.modules.xml.schema.model,\
9.118 + org.netbeans.modules.xml.tax,\
9.119 + org.netbeans.modules.xml.text,\
9.120 + org.netbeans.modules.xml.tools,\
9.121 + org.netbeans.modules.xml.wsdl.model,\
9.122 + org.netbeans.modules.xml.xam,\
9.123 + org.netbeans.modules.xml.xdm,\
9.124 + org.netbeans.modules.xsl,\
9.125 + org.netbeans.spi.debugger.ui,\
9.126 + org.netbeans.spi.navigator,\
9.127 + org.netbeans.spi.palette,\
9.128 + org.netbeans.spi.viewmodel,\
9.129 + org.netbeans.tasklistapi,\
9.130 + org.openide.src,\
9.131 + org.openidex.util
9.132 +enabled.clusters=\
9.133 + ide7,\
9.134 + platform6
9.135 +nbplatform.active=default
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
10.2 +++ b/platform/samples/AudioStation/fftview/nbproject/project.properties Thu Nov 02 01:01:27 2006 +0000
10.3 @@ -0,0 +1,1 @@
10.4 +javac.source=1.5
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
11.2 +++ b/platform/samples/AudioStation/fftview/nbproject/project.xml Thu Nov 02 01:01:27 2006 +0000
11.3 @@ -0,0 +1,78 @@
11.4 +<?xml version="1.0" encoding="UTF-8"?>
11.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
11.6 + <type>org.netbeans.modules.apisupport.project</type>
11.7 + <configuration>
11.8 + <data xmlns="http://www.netbeans.org/ns/nb-module-project/2">
11.9 + <code-name-base>org.foo.fftview</code-name-base>
11.10 + <suite-component/>
11.11 + <module-dependencies>
11.12 + <dependency>
11.13 + <code-name-base>org.foo.wavsupport</code-name-base>
11.14 + <build-prerequisite/>
11.15 + <compile-dependency/>
11.16 + <run-dependency>
11.17 + <specification-version>1.0</specification-version>
11.18 + </run-dependency>
11.19 + </dependency>
11.20 + <dependency>
11.21 + <code-name-base>org.foo.wavutils</code-name-base>
11.22 + <build-prerequisite/>
11.23 + <compile-dependency/>
11.24 + <run-dependency>
11.25 + <specification-version>1.0</specification-version>
11.26 + </run-dependency>
11.27 + </dependency>
11.28 + <dependency>
11.29 + <code-name-base>org.netbeans.core.multiview</code-name-base>
11.30 + <build-prerequisite/>
11.31 + <compile-dependency/>
11.32 + <run-dependency>
11.33 + <release-version>1</release-version>
11.34 + <specification-version>1.8.22</specification-version>
11.35 + </run-dependency>
11.36 + </dependency>
11.37 + <dependency>
11.38 + <code-name-base>org.openide.awt</code-name-base>
11.39 + <build-prerequisite/>
11.40 + <compile-dependency/>
11.41 + <run-dependency>
11.42 + <specification-version>6.7.22</specification-version>
11.43 + </run-dependency>
11.44 + </dependency>
11.45 + <dependency>
11.46 + <code-name-base>org.openide.loaders</code-name-base>
11.47 + <build-prerequisite/>
11.48 + <compile-dependency/>
11.49 + <run-dependency>
11.50 + <specification-version>5.9.22</specification-version>
11.51 + </run-dependency>
11.52 + </dependency>
11.53 + <dependency>
11.54 + <code-name-base>org.openide.nodes</code-name-base>
11.55 + <build-prerequisite/>
11.56 + <compile-dependency/>
11.57 + <run-dependency>
11.58 + <specification-version>6.7.22</specification-version>
11.59 + </run-dependency>
11.60 + </dependency>
11.61 + <dependency>
11.62 + <code-name-base>org.openide.util</code-name-base>
11.63 + <build-prerequisite/>
11.64 + <compile-dependency/>
11.65 + <run-dependency>
11.66 + <specification-version>6.8.22</specification-version>
11.67 + </run-dependency>
11.68 + </dependency>
11.69 + <dependency>
11.70 + <code-name-base>org.openide.windows</code-name-base>
11.71 + <build-prerequisite/>
11.72 + <compile-dependency/>
11.73 + <run-dependency>
11.74 + <specification-version>6.5.22</specification-version>
11.75 + </run-dependency>
11.76 + </dependency>
11.77 + </module-dependencies>
11.78 + <public-packages/>
11.79 + </data>
11.80 + </configuration>
11.81 +</project>
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
12.2 +++ b/platform/samples/AudioStation/fftview/nbproject/suite.properties Thu Nov 02 01:01:27 2006 +0000
12.3 @@ -0,0 +1,1 @@
12.4 +suite.dir=${basedir}/..
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
13.2 +++ b/platform/samples/AudioStation/fftview/src/META-INF/services/org.foo.wavsupport.api.WavViewDescriptor Thu Nov 02 01:01:27 2006 +0000
13.3 @@ -0,0 +1,1 @@
13.4 +org.foo.fftview.FFTViewDescriptor
13.5 \ No newline at end of file
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
14.2 +++ b/platform/samples/AudioStation/fftview/src/org/foo/fftview/Bundle.properties Thu Nov 02 01:01:27 2006 +0000
14.3 @@ -0,0 +1,1 @@
14.4 +OpenIDE-Module-Name=fftview
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
15.2 +++ b/platform/samples/AudioStation/fftview/src/org/foo/fftview/FFTViewDescriptor.java Thu Nov 02 01:01:27 2006 +0000
15.3 @@ -0,0 +1,75 @@
15.4 +/*
15.5 + * The contents of this file are subject to the terms of the Common Development
15.6 + * and Distribution License (the License). You may not use this file except in
15.7 + * compliance with the License.
15.8 + *
15.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
15.10 + * or http://www.netbeans.org/cddl.txt.
15.11 + *
15.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
15.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
15.14 + * If applicable, add the following below the CDDL Header, with the fields
15.15 + * enclosed by brackets [] replaced by your own identifying information:
15.16 + * "Portions Copyrighted [year] [name of copyright owner]"
15.17 + */
15.18 +
15.19 +
15.20 +package org.foo.fftview;
15.21 +
15.22 +import java.awt.Image;
15.23 +import java.io.IOException;
15.24 +import java.io.ObjectOutputStream;
15.25 +import java.io.Serializable;
15.26 +import org.foo.wavsupport.api.WavViewDescriptor;
15.27 +import org.netbeans.core.spi.multiview.MultiViewElement;
15.28 +import org.openide.loaders.DataObject;
15.29 +import org.openide.util.HelpCtx;
15.30 +import org.openide.util.Utilities;
15.31 +import org.openide.windows.TopComponent;
15.32 +
15.33 +/**
15.34 + *
15.35 + * @author runger
15.36 + */
15.37 +public class FFTViewDescriptor implements WavViewDescriptor, Serializable {
15.38 +
15.39 + private static final long serialVersionUID = 1L;
15.40 +
15.41 + public static Image ICON = Utilities.loadImage("org/foo/wavutils/sampleGraph.gif");
15.42 +
15.43 + private DataObject dobj;
15.44 +
15.45 + public int getPersistenceType() {
15.46 + return TopComponent.PERSISTENCE_ALWAYS;
15.47 + }
15.48 +
15.49 + public String getDisplayName() {
15.50 + return "Frequency Domain";
15.51 + }
15.52 +
15.53 + public Image getIcon() {
15.54 + return ICON;
15.55 + }
15.56 +
15.57 + public HelpCtx getHelpCtx() {
15.58 + return null;
15.59 + }
15.60 +
15.61 + public String preferredID() {
15.62 + return "FFT";
15.63 + }
15.64 +
15.65 + public MultiViewElement createElement() {
15.66 + return new FFTTopComponent(dobj);
15.67 + }
15.68 +
15.69 + public void setWavDataObject(DataObject wav) {
15.70 + dobj = wav;
15.71 + }
15.72 +
15.73 + private void writeObject(ObjectOutputStream out) throws IOException
15.74 + {
15.75 + out.defaultWriteObject();
15.76 + }
15.77 +
15.78 +}
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
16.2 +++ b/platform/samples/AudioStation/fftview/src/org/foo/fftview/layer.xml Thu Nov 02 01:01:27 2006 +0000
16.3 @@ -0,0 +1,5 @@
16.4 +<?xml version="1.0" encoding="UTF-8"?>
16.5 +<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
16.6 +<filesystem>
16.7 +</filesystem>
16.8 +
17.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
17.2 +++ b/platform/samples/AudioStation/nbproject/build-impl.xml Thu Nov 02 01:01:27 2006 +0000
17.3 @@ -0,0 +1,27 @@
17.4 +<?xml version="1.0" encoding="UTF-8"?>
17.5 +<!--
17.6 +*** GENERATED FROM project.xml - DO NOT EDIT ***
17.7 +*** EDIT ../build.xml INSTEAD ***
17.8 +-->
17.9 +<project name="AudioStation-impl" basedir=".." xmlns:sproject="http://www.netbeans.org/ns/nb-module-suite-project/1">
17.10 + <property file="nbproject/private/platform-private.properties"/>
17.11 + <property file="nbproject/platform.properties"/>
17.12 + <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-suite-project/1">
17.13 + <attribute name="name"/>
17.14 + <attribute name="value"/>
17.15 + <sequential>
17.16 + <property name="@{name}" value="${@{value}}"/>
17.17 + </sequential>
17.18 + </macrodef>
17.19 + <property file="${user.properties.file}"/>
17.20 + <sproject:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir"/>
17.21 + <sproject:property name="netbeans.dest.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir"/>
17.22 + <fail message="You must define 'nbplatform.${nbplatform.active}.harness.dir'">
17.23 + <condition>
17.24 + <not>
17.25 + <available file="${harness.dir}" type="dir"/>
17.26 + </not>
17.27 + </condition>
17.28 + </fail>
17.29 + <import file="${harness.dir}/suite.xml"/>
17.30 +</project>
18.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
18.2 +++ b/platform/samples/AudioStation/nbproject/genfiles.properties Thu Nov 02 01:01:27 2006 +0000
18.3 @@ -0,0 +1,8 @@
18.4 +build.xml.data.CRC32=da094077
18.5 +build.xml.script.CRC32=d1d030b1
18.6 +build.xml.stylesheet.CRC32=722e7a4f
18.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
18.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
18.9 +nbproject/build-impl.xml.data.CRC32=da094077
18.10 +nbproject/build-impl.xml.script.CRC32=f8e6aa18
18.11 +nbproject/build-impl.xml.stylesheet.CRC32=121e7282
19.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
19.2 +++ b/platform/samples/AudioStation/nbproject/platform.properties Thu Nov 02 01:01:27 2006 +0000
19.3 @@ -0,0 +1,132 @@
19.4 +# Deprecated since 5.0u1; for compatibility with 5.0:
19.5 +disabled.clusters=\
19.6 + enterprise3,\
19.7 + harness,\
19.8 + nb5.5
19.9 +disabled.modules=\
19.10 + javax.jmi.model,\
19.11 + javax.jmi.reflect,\
19.12 + org.apache.tools.ant.module,\
19.13 + org.apache.xml.resolver,\
19.14 + org.netbeans.api.debugger,\
19.15 + org.netbeans.api.debugger.jpda,\
19.16 + org.netbeans.api.java,\
19.17 + org.netbeans.api.mdr,\
19.18 + org.netbeans.api.xml,\
19.19 + org.netbeans.core.ide,\
19.20 + org.netbeans.jmi.javamodel,\
19.21 + org.netbeans.lib.cvsclient,\
19.22 + org.netbeans.libs.commons_logging,\
19.23 + org.netbeans.libs.formlayout,\
19.24 + org.netbeans.libs.jsch,\
19.25 + org.netbeans.libs.xerces,\
19.26 + org.netbeans.modules.ant.browsetask,\
19.27 + org.netbeans.modules.ant.debugger,\
19.28 + org.netbeans.modules.ant.freeform,\
19.29 + org.netbeans.modules.ant.grammar,\
19.30 + org.netbeans.modules.apisupport.ant,\
19.31 + org.netbeans.modules.apisupport.feedreader,\
19.32 + org.netbeans.modules.apisupport.paintapp,\
19.33 + org.netbeans.modules.apisupport.project,\
19.34 + org.netbeans.modules.apisupport.refactoring,\
19.35 + org.netbeans.modules.beans,\
19.36 + org.netbeans.modules.classfile,\
19.37 + org.netbeans.modules.clazz,\
19.38 + org.netbeans.modules.css,\
19.39 + org.netbeans.modules.db,\
19.40 + org.netbeans.modules.db.core,\
19.41 + org.netbeans.modules.db.sql.editor,\
19.42 + org.netbeans.modules.dbapi,\
19.43 + org.netbeans.modules.debugger.jpda,\
19.44 + org.netbeans.modules.debugger.jpda.ant,\
19.45 + org.netbeans.modules.debugger.jpda.ui,\
19.46 + org.netbeans.modules.defaults,\
19.47 + org.netbeans.modules.diff,\
19.48 + org.netbeans.modules.editor,\
19.49 + org.netbeans.modules.editor.bookmarks,\
19.50 + org.netbeans.modules.editor.codetemplates,\
19.51 + org.netbeans.modules.editor.completion,\
19.52 + org.netbeans.modules.editor.errorstripe,\
19.53 + org.netbeans.modules.editor.errorstripe.api,\
19.54 + org.netbeans.modules.editor.hints,\
19.55 + org.netbeans.modules.editor.plain,\
19.56 + org.netbeans.modules.editor.plain.lib,\
19.57 + org.netbeans.modules.editor.settings,\
19.58 + org.netbeans.modules.editor.settings.storage,\
19.59 + org.netbeans.modules.editor.structure,\
19.60 + org.netbeans.modules.extbrowser,\
19.61 + org.netbeans.modules.form,\
19.62 + org.netbeans.modules.html,\
19.63 + org.netbeans.modules.html.editor,\
19.64 + org.netbeans.modules.html.editor.lib,\
19.65 + org.netbeans.modules.httpserver,\
19.66 + org.netbeans.modules.i18n,\
19.67 + org.netbeans.modules.i18n.form,\
19.68 + org.netbeans.modules.image,\
19.69 + org.netbeans.modules.j2ee.metadata,\
19.70 + org.netbeans.modules.j2ee.persistenceapi,\
19.71 + org.netbeans.modules.java,\
19.72 + org.netbeans.modules.java.editor,\
19.73 + org.netbeans.modules.java.editor.lib,\
19.74 + org.netbeans.modules.java.examples,\
19.75 + org.netbeans.modules.java.freeform,\
19.76 + org.netbeans.modules.java.hints,\
19.77 + org.netbeans.modules.java.j2seplatform,\
19.78 + org.netbeans.modules.java.j2seproject,\
19.79 + org.netbeans.modules.java.navigation,\
19.80 + org.netbeans.modules.java.platform,\
19.81 + org.netbeans.modules.java.project,\
19.82 + org.netbeans.modules.javacore,\
19.83 + org.netbeans.modules.javadoc,\
19.84 + org.netbeans.modules.jmiutils,\
19.85 + org.netbeans.modules.junit,\
19.86 + org.netbeans.modules.mdr,\
19.87 + org.netbeans.modules.options.api,\
19.88 + org.netbeans.modules.options.editor,\
19.89 + org.netbeans.modules.project.ant,\
19.90 + org.netbeans.modules.project.libraries,\
19.91 + org.netbeans.modules.projectapi,\
19.92 + org.netbeans.modules.projectui,\
19.93 + org.netbeans.modules.projectuiapi,\
19.94 + org.netbeans.modules.properties,\
19.95 + org.netbeans.modules.properties.syntax,\
19.96 + org.netbeans.modules.refactoring,\
19.97 + org.netbeans.modules.schema2beans,\
19.98 + org.netbeans.modules.servletapi,\
19.99 + org.netbeans.modules.suggestions_framework,\
19.100 + org.netbeans.modules.tasklist.core,\
19.101 + org.netbeans.modules.tasklist.docscan,\
19.102 + org.netbeans.modules.usersguide,\
19.103 + org.netbeans.modules.utilities,\
19.104 + org.netbeans.modules.utilities.project,\
19.105 + org.netbeans.modules.versioning,\
19.106 + org.netbeans.modules.versioning.system.cvss,\
19.107 + org.netbeans.modules.websvc.clientapi,\
19.108 + org.netbeans.modules.websvc.jaxrpc16,\
19.109 + org.netbeans.modules.websvc.jaxws20,\
19.110 + org.netbeans.modules.websvc.jaxwsapi,\
19.111 + org.netbeans.modules.websvc.jaxwsmodel,\
19.112 + org.netbeans.modules.xml.catalog,\
19.113 + org.netbeans.modules.xml.core,\
19.114 + org.netbeans.modules.xml.multiview,\
19.115 + org.netbeans.modules.xml.retriever,\
19.116 + org.netbeans.modules.xml.schema,\
19.117 + org.netbeans.modules.xml.schema.model,\
19.118 + org.netbeans.modules.xml.tax,\
19.119 + org.netbeans.modules.xml.text,\
19.120 + org.netbeans.modules.xml.tools,\
19.121 + org.netbeans.modules.xml.wsdl.model,\
19.122 + org.netbeans.modules.xml.xam,\
19.123 + org.netbeans.modules.xml.xdm,\
19.124 + org.netbeans.modules.xsl,\
19.125 + org.netbeans.spi.debugger.ui,\
19.126 + org.netbeans.spi.navigator,\
19.127 + org.netbeans.spi.palette,\
19.128 + org.netbeans.spi.viewmodel,\
19.129 + org.netbeans.tasklistapi,\
19.130 + org.openide.src,\
19.131 + org.openidex.util
19.132 +enabled.clusters=\
19.133 + ide7,\
19.134 + platform6
19.135 +nbplatform.active=default
20.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
20.2 +++ b/platform/samples/AudioStation/nbproject/project.properties Thu Nov 02 01:01:27 2006 +0000
20.3 @@ -0,0 +1,11 @@
20.4 +app.icon=branding/core/core.jar/org/netbeans/core/startup/frame48.gif
20.5 +app.name=audiostation
20.6 +app.title=AudioStation
20.7 +branding.token=${app.name}
20.8 +modules=\
20.9 + ${project.org.foo.wavutils}:\
20.10 + ${project.org.foo.wavsupport}:\
20.11 + ${project.org.foo.fftview}
20.12 +project.org.foo.fftview=fftview
20.13 +project.org.foo.wavsupport=wavsupport
20.14 +project.org.foo.wavutils=wavutils
21.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
21.2 +++ b/platform/samples/AudioStation/nbproject/project.xml Thu Nov 02 01:01:27 2006 +0000
21.3 @@ -0,0 +1,9 @@
21.4 +<?xml version="1.0" encoding="UTF-8"?>
21.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
21.6 + <type>org.netbeans.modules.apisupport.project.suite</type>
21.7 + <configuration>
21.8 + <data xmlns="http://www.netbeans.org/ns/nb-module-suite-project/1">
21.9 + <name>AudioStation</name>
21.10 + </data>
21.11 + </configuration>
21.12 +</project>
22.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
22.2 +++ b/platform/samples/AudioStation/wavsupport/build.xml Thu Nov 02 01:01:27 2006 +0000
22.3 @@ -0,0 +1,8 @@
22.4 +<?xml version="1.0" encoding="UTF-8"?>
22.5 +<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
22.6 +<!-- for some information on what you could do (e.g. targets to override). -->
22.7 +<!-- If you delete this file and reopen the project it will be recreated. -->
22.8 +<project name="org.foo.wavsupport" default="netbeans" basedir=".">
22.9 + <description>Builds, tests, and runs the project org.foo.wavsupport.</description>
22.10 + <import file="nbproject/build-impl.xml"/>
22.11 +</project>
23.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
23.2 +++ b/platform/samples/AudioStation/wavsupport/manifest.mf Thu Nov 02 01:01:27 2006 +0000
23.3 @@ -0,0 +1,9 @@
23.4 +Manifest-Version: 1.0
23.5 +OpenIDE-Module: org.foo.wavsupport
23.6 +OpenIDE-Module-Layer: org/foo/wavsupport/layer.xml
23.7 +OpenIDE-Module-Localizing-Bundle: org/foo/wavsupport/Bundle.properties
23.8 +OpenIDE-Module-Specification-Version: 1.0
23.9 +
23.10 +Name: org/foo/wavsupport/WavDataLoader.class
23.11 +OpenIDE-Module-Class: Loader
23.12 +
24.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
24.2 +++ b/platform/samples/AudioStation/wavsupport/nbproject/build-impl.xml Thu Nov 02 01:01:27 2006 +0000
24.3 @@ -0,0 +1,30 @@
24.4 +<?xml version="1.0" encoding="UTF-8"?>
24.5 +<!--
24.6 +*** GENERATED FROM project.xml - DO NOT EDIT ***
24.7 +*** EDIT ../build.xml INSTEAD ***
24.8 +-->
24.9 +<project name="org.foo.wavsupport-impl" basedir=".." xmlns:nbmproject="http://www.netbeans.org/ns/nb-module-project/2">
24.10 + <property file="nbproject/private/suite-private.properties"/>
24.11 + <property file="nbproject/suite.properties"/>
24.12 + <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
24.13 + <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
24.14 + <property file="${suite.dir}/nbproject/platform.properties"/>
24.15 + <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
24.16 + <attribute name="name"/>
24.17 + <attribute name="value"/>
24.18 + <sequential>
24.19 + <property name="@{name}" value="${@{value}}"/>
24.20 + </sequential>
24.21 + </macrodef>
24.22 + <property file="${user.properties.file}"/>
24.23 + <nbmproject:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir"/>
24.24 + <nbmproject:property name="netbeans.dest.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir"/>
24.25 + <fail message="You must define 'nbplatform.${nbplatform.active}.harness.dir'">
24.26 + <condition>
24.27 + <not>
24.28 + <available file="${harness.dir}" type="dir"/>
24.29 + </not>
24.30 + </condition>
24.31 + </fail>
24.32 + <import file="${harness.dir}/build.xml"/>
24.33 +</project>
25.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
25.2 +++ b/platform/samples/AudioStation/wavsupport/nbproject/genfiles.properties Thu Nov 02 01:01:27 2006 +0000
25.3 @@ -0,0 +1,8 @@
25.4 +build.xml.data.CRC32=65e3160d
25.5 +build.xml.script.CRC32=959517cb
25.6 +build.xml.stylesheet.CRC32=77ef55dd
25.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
25.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
25.9 +nbproject/build-impl.xml.data.CRC32=65e3160d
25.10 +nbproject/build-impl.xml.script.CRC32=888d9d52
25.11 +nbproject/build-impl.xml.stylesheet.CRC32=2607fe5f
26.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
26.2 +++ b/platform/samples/AudioStation/wavsupport/nbproject/platform.properties Thu Nov 02 01:01:27 2006 +0000
26.3 @@ -0,0 +1,132 @@
26.4 +# Deprecated since 5.0u1; for compatibility with 5.0:
26.5 +disabled.clusters=\
26.6 + enterprise3,\
26.7 + harness,\
26.8 + nb5.5
26.9 +disabled.modules=\
26.10 + javax.jmi.model,\
26.11 + javax.jmi.reflect,\
26.12 + org.apache.tools.ant.module,\
26.13 + org.apache.xml.resolver,\
26.14 + org.netbeans.api.debugger,\
26.15 + org.netbeans.api.debugger.jpda,\
26.16 + org.netbeans.api.java,\
26.17 + org.netbeans.api.mdr,\
26.18 + org.netbeans.api.xml,\
26.19 + org.netbeans.core.ide,\
26.20 + org.netbeans.jmi.javamodel,\
26.21 + org.netbeans.lib.cvsclient,\
26.22 + org.netbeans.libs.commons_logging,\
26.23 + org.netbeans.libs.formlayout,\
26.24 + org.netbeans.libs.jsch,\
26.25 + org.netbeans.libs.xerces,\
26.26 + org.netbeans.modules.ant.browsetask,\
26.27 + org.netbeans.modules.ant.debugger,\
26.28 + org.netbeans.modules.ant.freeform,\
26.29 + org.netbeans.modules.ant.grammar,\
26.30 + org.netbeans.modules.apisupport.ant,\
26.31 + org.netbeans.modules.apisupport.feedreader,\
26.32 + org.netbeans.modules.apisupport.paintapp,\
26.33 + org.netbeans.modules.apisupport.project,\
26.34 + org.netbeans.modules.apisupport.refactoring,\
26.35 + org.netbeans.modules.beans,\
26.36 + org.netbeans.modules.classfile,\
26.37 + org.netbeans.modules.clazz,\
26.38 + org.netbeans.modules.css,\
26.39 + org.netbeans.modules.db,\
26.40 + org.netbeans.modules.db.core,\
26.41 + org.netbeans.modules.db.sql.editor,\
26.42 + org.netbeans.modules.dbapi,\
26.43 + org.netbeans.modules.debugger.jpda,\
26.44 + org.netbeans.modules.debugger.jpda.ant,\
26.45 + org.netbeans.modules.debugger.jpda.ui,\
26.46 + org.netbeans.modules.defaults,\
26.47 + org.netbeans.modules.diff,\
26.48 + org.netbeans.modules.editor,\
26.49 + org.netbeans.modules.editor.bookmarks,\
26.50 + org.netbeans.modules.editor.codetemplates,\
26.51 + org.netbeans.modules.editor.completion,\
26.52 + org.netbeans.modules.editor.errorstripe,\
26.53 + org.netbeans.modules.editor.errorstripe.api,\
26.54 + org.netbeans.modules.editor.hints,\
26.55 + org.netbeans.modules.editor.plain,\
26.56 + org.netbeans.modules.editor.plain.lib,\
26.57 + org.netbeans.modules.editor.settings,\
26.58 + org.netbeans.modules.editor.settings.storage,\
26.59 + org.netbeans.modules.editor.structure,\
26.60 + org.netbeans.modules.extbrowser,\
26.61 + org.netbeans.modules.form,\
26.62 + org.netbeans.modules.html,\
26.63 + org.netbeans.modules.html.editor,\
26.64 + org.netbeans.modules.html.editor.lib,\
26.65 + org.netbeans.modules.httpserver,\
26.66 + org.netbeans.modules.i18n,\
26.67 + org.netbeans.modules.i18n.form,\
26.68 + org.netbeans.modules.image,\
26.69 + org.netbeans.modules.j2ee.metadata,\
26.70 + org.netbeans.modules.j2ee.persistenceapi,\
26.71 + org.netbeans.modules.java,\
26.72 + org.netbeans.modules.java.editor,\
26.73 + org.netbeans.modules.java.editor.lib,\
26.74 + org.netbeans.modules.java.examples,\
26.75 + org.netbeans.modules.java.freeform,\
26.76 + org.netbeans.modules.java.hints,\
26.77 + org.netbeans.modules.java.j2seplatform,\
26.78 + org.netbeans.modules.java.j2seproject,\
26.79 + org.netbeans.modules.java.navigation,\
26.80 + org.netbeans.modules.java.platform,\
26.81 + org.netbeans.modules.java.project,\
26.82 + org.netbeans.modules.javacore,\
26.83 + org.netbeans.modules.javadoc,\
26.84 + org.netbeans.modules.jmiutils,\
26.85 + org.netbeans.modules.junit,\
26.86 + org.netbeans.modules.mdr,\
26.87 + org.netbeans.modules.options.api,\
26.88 + org.netbeans.modules.options.editor,\
26.89 + org.netbeans.modules.project.ant,\
26.90 + org.netbeans.modules.project.libraries,\
26.91 + org.netbeans.modules.projectapi,\
26.92 + org.netbeans.modules.projectui,\
26.93 + org.netbeans.modules.projectuiapi,\
26.94 + org.netbeans.modules.properties,\
26.95 + org.netbeans.modules.properties.syntax,\
26.96 + org.netbeans.modules.refactoring,\
26.97 + org.netbeans.modules.schema2beans,\
26.98 + org.netbeans.modules.servletapi,\
26.99 + org.netbeans.modules.suggestions_framework,\
26.100 + org.netbeans.modules.tasklist.core,\
26.101 + org.netbeans.modules.tasklist.docscan,\
26.102 + org.netbeans.modules.usersguide,\
26.103 + org.netbeans.modules.utilities,\
26.104 + org.netbeans.modules.utilities.project,\
26.105 + org.netbeans.modules.versioning,\
26.106 + org.netbeans.modules.versioning.system.cvss,\
26.107 + org.netbeans.modules.websvc.clientapi,\
26.108 + org.netbeans.modules.websvc.jaxrpc16,\
26.109 + org.netbeans.modules.websvc.jaxws20,\
26.110 + org.netbeans.modules.websvc.jaxwsapi,\
26.111 + org.netbeans.modules.websvc.jaxwsmodel,\
26.112 + org.netbeans.modules.xml.catalog,\
26.113 + org.netbeans.modules.xml.core,\
26.114 + org.netbeans.modules.xml.multiview,\
26.115 + org.netbeans.modules.xml.retriever,\
26.116 + org.netbeans.modules.xml.schema,\
26.117 + org.netbeans.modules.xml.schema.model,\
26.118 + org.netbeans.modules.xml.tax,\
26.119 + org.netbeans.modules.xml.text,\
26.120 + org.netbeans.modules.xml.tools,\
26.121 + org.netbeans.modules.xml.wsdl.model,\
26.122 + org.netbeans.modules.xml.xam,\
26.123 + org.netbeans.modules.xml.xdm,\
26.124 + org.netbeans.modules.xsl,\
26.125 + org.netbeans.spi.debugger.ui,\
26.126 + org.netbeans.spi.navigator,\
26.127 + org.netbeans.spi.palette,\
26.128 + org.netbeans.spi.viewmodel,\
26.129 + org.netbeans.tasklistapi,\
26.130 + org.openide.src,\
26.131 + org.openidex.util
26.132 +enabled.clusters=\
26.133 + ide7,\
26.134 + platform6
26.135 +nbplatform.active=default
27.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
27.2 +++ b/platform/samples/AudioStation/wavsupport/nbproject/project.properties Thu Nov 02 01:01:27 2006 +0000
27.3 @@ -0,0 +1,1 @@
27.4 +javac.source=1.5
28.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
28.2 +++ b/platform/samples/AudioStation/wavsupport/nbproject/project.xml Thu Nov 02 01:01:27 2006 +0000
28.3 @@ -0,0 +1,104 @@
28.4 +<?xml version="1.0" encoding="UTF-8"?>
28.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
28.6 + <type>org.netbeans.modules.apisupport.project</type>
28.7 + <configuration>
28.8 + <data xmlns="http://www.netbeans.org/ns/nb-module-project/2">
28.9 + <code-name-base>org.foo.wavsupport</code-name-base>
28.10 + <suite-component/>
28.11 + <module-dependencies>
28.12 + <dependency>
28.13 + <code-name-base>org.foo.wavutils</code-name-base>
28.14 + <build-prerequisite/>
28.15 + <compile-dependency/>
28.16 + <run-dependency>
28.17 + <specification-version>1.0</specification-version>
28.18 + </run-dependency>
28.19 + </dependency>
28.20 + <dependency>
28.21 + <code-name-base>org.netbeans.core.multiview</code-name-base>
28.22 + <build-prerequisite/>
28.23 + <compile-dependency/>
28.24 + <run-dependency>
28.25 + <release-version>1</release-version>
28.26 + <specification-version>1.8.22</specification-version>
28.27 + </run-dependency>
28.28 + </dependency>
28.29 + <dependency>
28.30 + <code-name-base>org.netbeans.modules.editor.lib</code-name-base>
28.31 + <build-prerequisite/>
28.32 + <compile-dependency/>
28.33 + <run-dependency>
28.34 + <release-version>1</release-version>
28.35 + <specification-version>1.9.22.1</specification-version>
28.36 + </run-dependency>
28.37 + </dependency>
28.38 + <dependency>
28.39 + <code-name-base>org.netbeans.modules.favorites</code-name-base>
28.40 + <run-dependency>
28.41 + <release-version>1</release-version>
28.42 + <specification-version>1.11.23</specification-version>
28.43 + </run-dependency>
28.44 + </dependency>
28.45 + <dependency>
28.46 + <code-name-base>org.openide.awt</code-name-base>
28.47 + <build-prerequisite/>
28.48 + <compile-dependency/>
28.49 + <run-dependency>
28.50 + <specification-version>6.7.22</specification-version>
28.51 + </run-dependency>
28.52 + </dependency>
28.53 + <dependency>
28.54 + <code-name-base>org.openide.dialogs</code-name-base>
28.55 + <build-prerequisite/>
28.56 + <compile-dependency/>
28.57 + <run-dependency>
28.58 + <specification-version>6.5.22</specification-version>
28.59 + </run-dependency>
28.60 + </dependency>
28.61 + <dependency>
28.62 + <code-name-base>org.openide.filesystems</code-name-base>
28.63 + <build-prerequisite/>
28.64 + <compile-dependency/>
28.65 + <run-dependency>
28.66 + <specification-version>6.4.22</specification-version>
28.67 + </run-dependency>
28.68 + </dependency>
28.69 + <dependency>
28.70 + <code-name-base>org.openide.loaders</code-name-base>
28.71 + <build-prerequisite/>
28.72 + <compile-dependency/>
28.73 + <run-dependency>
28.74 + <specification-version>5.9.22</specification-version>
28.75 + </run-dependency>
28.76 + </dependency>
28.77 + <dependency>
28.78 + <code-name-base>org.openide.nodes</code-name-base>
28.79 + <build-prerequisite/>
28.80 + <compile-dependency/>
28.81 + <run-dependency>
28.82 + <specification-version>6.7.22</specification-version>
28.83 + </run-dependency>
28.84 + </dependency>
28.85 + <dependency>
28.86 + <code-name-base>org.openide.util</code-name-base>
28.87 + <build-prerequisite/>
28.88 + <compile-dependency/>
28.89 + <run-dependency>
28.90 + <specification-version>6.8.22</specification-version>
28.91 + </run-dependency>
28.92 + </dependency>
28.93 + <dependency>
28.94 + <code-name-base>org.openide.windows</code-name-base>
28.95 + <build-prerequisite/>
28.96 + <compile-dependency/>
28.97 + <run-dependency>
28.98 + <specification-version>6.5.22</specification-version>
28.99 + </run-dependency>
28.100 + </dependency>
28.101 + </module-dependencies>
28.102 + <public-packages>
28.103 + <package>org.foo.wavsupport.api</package>
28.104 + </public-packages>
28.105 + </data>
28.106 + </configuration>
28.107 +</project>
29.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
29.2 +++ b/platform/samples/AudioStation/wavsupport/nbproject/suite.properties Thu Nov 02 01:01:27 2006 +0000
29.3 @@ -0,0 +1,1 @@
29.4 +suite.dir=${basedir}/..
30.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
30.2 +++ b/platform/samples/AudioStation/wavsupport/src/org/foo/wavsupport/Bundle.properties Thu Nov 02 01:01:27 2006 +0000
30.3 @@ -0,0 +1,16 @@
30.4 +LBL_Wav_loader_name=Wav Files
30.5 +OpenIDE-Module-Name=wavsupport
30.6 +OpenIDE-Module-Short-Description=Edits WAV files
30.7 +Services/MIMEResolver/WavResolver.xml=Wav Files
30.8 +Templates/Other/WavTemplate.wav=Empty Wav file
30.9 +
30.10 +
30.11 +LBL_SampleRate=Sample Rate
30.12 +LBL_Channels=Channels
30.13 +LBL_Encoding=Encoding
30.14 +LBL_FrameRate=Frame Rate
30.15 +LBL_FrameSize=Frame Size
30.16 +LBL_SampleSize=Sample Size (bits)
30.17 +LBL_Endian=Endian
30.18 +LBL_BigEndian=Big Endian
30.19 +LBL_LittleEndian=Little Endian
31.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
31.2 +++ b/platform/samples/AudioStation/wavsupport/src/org/foo/wavsupport/WavDataLoader.java Thu Nov 02 01:01:27 2006 +0000
31.3 @@ -0,0 +1,52 @@
31.4 +/*
31.5 + * The contents of this file are subject to the terms of the Common Development
31.6 + * and Distribution License (the License). You may not use this file except in
31.7 + * compliance with the License.
31.8 + *
31.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
31.10 + * or http://www.netbeans.org/cddl.txt.
31.11 + *
31.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
31.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
31.14 + * If applicable, add the following below the CDDL Header, with the fields
31.15 + * enclosed by brackets [] replaced by your own identifying information:
31.16 + * "Portions Copyrighted [year] [name of copyright owner]"
31.17 + */
31.18 +package org.foo.wavsupport;
31.19 +
31.20 +import java.io.IOException;
31.21 +import org.foo.wavsupport.WavDataObject;
31.22 +import org.openide.filesystems.FileObject;
31.23 +import org.openide.loaders.DataObjectExistsException;
31.24 +import org.openide.loaders.MultiDataObject;
31.25 +import org.openide.loaders.UniFileLoader;
31.26 +import org.openide.util.NbBundle;
31.27 +
31.28 +public class WavDataLoader extends UniFileLoader {
31.29 +
31.30 + public static final String REQUIRED_MIME = "audio/wav";
31.31 +
31.32 + private static final long serialVersionUID = 1L;
31.33 +
31.34 + public WavDataLoader() {
31.35 + super("org.foo.wavsupport.WavDataObject");
31.36 + }
31.37 +
31.38 + protected String defaultDisplayName() {
31.39 + return NbBundle.getMessage(WavDataLoader.class, "LBL_Wav_loader_name");
31.40 + }
31.41 +
31.42 + protected void initialize() {
31.43 + super.initialize();
31.44 + getExtensions().addMimeType(REQUIRED_MIME);
31.45 + }
31.46 +
31.47 + protected MultiDataObject createMultiObject(FileObject primaryFile) throws DataObjectExistsException, IOException {
31.48 + return new WavDataObject(primaryFile, this);
31.49 + }
31.50 +
31.51 + protected String actionsContext() {
31.52 + return "Loaders/" + REQUIRED_MIME + "/Actions";
31.53 + }
31.54 +
31.55 +}
32.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
32.2 +++ b/platform/samples/AudioStation/wavsupport/src/org/foo/wavsupport/WavDataLoaderBeanInfo.java Thu Nov 02 01:01:27 2006 +0000
32.3 @@ -0,0 +1,44 @@
32.4 +/*
32.5 + * The contents of this file are subject to the terms of the Common Development
32.6 + * and Distribution License (the License). You may not use this file except in
32.7 + * compliance with the License.
32.8 + *
32.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
32.10 + * or http://www.netbeans.org/cddl.txt.
32.11 + *
32.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
32.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
32.14 + * If applicable, add the following below the CDDL Header, with the fields
32.15 + * enclosed by brackets [] replaced by your own identifying information:
32.16 + * "Portions Copyrighted [year] [name of copyright owner]"
32.17 + */
32.18 +package org.foo.wavsupport;
32.19 +
32.20 +import java.awt.Image;
32.21 +import java.beans.BeanInfo;
32.22 +import java.beans.IntrospectionException;
32.23 +import java.beans.Introspector;
32.24 +import java.beans.SimpleBeanInfo;
32.25 +import org.openide.loaders.UniFileLoader;
32.26 +import org.openide.util.Utilities;
32.27 +
32.28 +public class WavDataLoaderBeanInfo extends SimpleBeanInfo {
32.29 +
32.30 + public BeanInfo[] getAdditionalBeanInfo() {
32.31 + try {
32.32 + return new BeanInfo[] {Introspector.getBeanInfo(UniFileLoader.class)};
32.33 + } catch (IntrospectionException e) {
32.34 + throw new AssertionError(e);
32.35 + }
32.36 + }
32.37 +
32.38 + public Image getIcon(int type) {
32.39 + if (type == BeanInfo.ICON_COLOR_16x16 || type == BeanInfo.ICON_MONO_16x16) {
32.40 + return Utilities.loadImage("org/foo/wavutils/wavIconSmall.gif");
32.41 + } else {
32.42 + return Utilities.loadImage("org/foo/wavutils/wavIcon.gif");
32.43 + }
32.44 +
32.45 + }
32.46 +
32.47 +}
33.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
33.2 +++ b/platform/samples/AudioStation/wavsupport/src/org/foo/wavsupport/WavDataNode.java Thu Nov 02 01:01:27 2006 +0000
33.3 @@ -0,0 +1,203 @@
33.4 +/*
33.5 + * The contents of this file are subject to the terms of the Common Development
33.6 + * and Distribution License (the License). You may not use this file except in
33.7 + * compliance with the License.
33.8 + *
33.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
33.10 + * or http://www.netbeans.org/cddl.txt.
33.11 + *
33.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
33.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
33.14 + * If applicable, add the following below the CDDL Header, with the fields
33.15 + * enclosed by brackets [] replaced by your own identifying information:
33.16 + * "Portions Copyrighted [year] [name of copyright owner]"
33.17 + */
33.18 +package org.foo.wavsupport;
33.19 +
33.20 +import java.lang.reflect.InvocationTargetException;
33.21 +import javax.sound.sampled.AudioFormat;
33.22 +import org.openide.ErrorManager;
33.23 +import org.openide.loaders.DataNode;
33.24 +import org.openide.nodes.BeanNode;
33.25 +import org.openide.nodes.Children;
33.26 +import org.openide.nodes.Node;
33.27 +import org.openide.nodes.Node.Property;
33.28 +import org.openide.nodes.Sheet;
33.29 +import org.openide.util.NbBundle;
33.30 +
33.31 +public class WavDataNode extends DataNode {
33.32 +
33.33 + private static final String IMAGE_ICON_BASE = "org/foo/wavutils/wavIconSmall.gif";
33.34 +
33.35 + public WavDataNode(WavDataObject obj) {
33.36 + super(obj, Children.LEAF);
33.37 + setIconBaseWithExtension(IMAGE_ICON_BASE);
33.38 + }
33.39 +
33.40 + /** Creates a property sheet. */
33.41 + protected Sheet createSheet() {
33.42 + Sheet s = super.createSheet();
33.43 + Sheet.Set ss = s.get(Sheet.PROPERTIES);
33.44 + if (ss == null) {
33.45 + ss = Sheet.createPropertiesSet();
33.46 + s.put(ss);
33.47 + }
33.48 +
33.49 + AudioFormat f = ((WavDataObject)getDataObject()).getAudioFormat();
33.50 +
33.51 + ss.put(new Encoding(f));
33.52 + ss.put(new Channels(f));
33.53 + ss.put(new FrameRate(f));
33.54 + ss.put(new FrameSize(f));
33.55 + ss.put(new SampleRate(f));
33.56 + ss.put(new SampleSize(f));
33.57 + ss.put(new Endian(f));
33.58 + return s;
33.59 + }
33.60 +
33.61 + private abstract class AudioFormatProperty extends Node.Property
33.62 + {
33.63 + private AudioFormat format;
33.64 +
33.65 + public AudioFormatProperty(AudioFormat f, Class clazz)
33.66 + {
33.67 + super(clazz);
33.68 + format = f;
33.69 + }
33.70 +
33.71 + protected AudioFormat getFormat()
33.72 + {
33.73 + return format;
33.74 + }
33.75 +
33.76 + public boolean canRead() { return true; }
33.77 + public boolean canWrite() { return false; }
33.78 +
33.79 + public void setValue(Object object) throws
33.80 + IllegalAccessException,
33.81 + IllegalArgumentException,
33.82 + InvocationTargetException {}
33.83 + }
33.84 +
33.85 + private class SampleRate extends AudioFormatProperty
33.86 + {
33.87 + public SampleRate(AudioFormat f)
33.88 + {
33.89 + super(f, Float.class);
33.90 + }
33.91 +
33.92 + public Object getValue() throws IllegalAccessException, InvocationTargetException
33.93 + {
33.94 + return getFormat().getSampleRate();
33.95 + }
33.96 +
33.97 + public String getName() {
33.98 + return NbBundle.getMessage(WavDataNode.class, "LBL_SampleRate");
33.99 + }
33.100 + }
33.101 +
33.102 + private class Channels extends AudioFormatProperty
33.103 + {
33.104 + public Channels(AudioFormat f)
33.105 + {
33.106 + super(f, Integer.class);
33.107 + }
33.108 +
33.109 + public Object getValue() throws IllegalAccessException, InvocationTargetException
33.110 + {
33.111 + return getFormat().getChannels();
33.112 + }
33.113 +
33.114 + public String getName() {
33.115 + return NbBundle.getMessage(WavDataNode.class, "LBL_Channels");
33.116 + }
33.117 + }
33.118 +
33.119 + private class Encoding extends AudioFormatProperty
33.120 + {
33.121 + public Encoding(AudioFormat f)
33.122 + {
33.123 + super(f, String.class);
33.124 + }
33.125 +
33.126 + public Object getValue() throws IllegalAccessException, InvocationTargetException
33.127 + {
33.128 + return getFormat().getEncoding().toString();
33.129 + }
33.130 +
33.131 + public String getName() {
33.132 + return NbBundle.getMessage(WavDataNode.class, "LBL_Encoding");
33.133 + }
33.134 + }
33.135 +
33.136 + private class FrameRate extends AudioFormatProperty
33.137 + {
33.138 + public FrameRate(AudioFormat f)
33.139 + {
33.140 + super(f, Float.class);
33.141 + }
33.142 +
33.143 + public Object getValue() throws IllegalAccessException, InvocationTargetException
33.144 + {
33.145 + return getFormat().getFrameRate();
33.146 + }
33.147 +
33.148 + public String getName() {
33.149 + return NbBundle.getMessage(WavDataNode.class, "LBL_FrameRate");
33.150 + }
33.151 + }
33.152 +
33.153 + private class FrameSize extends AudioFormatProperty
33.154 + {
33.155 + public FrameSize(AudioFormat f)
33.156 + {
33.157 + super(f, Integer.class);
33.158 + }
33.159 +
33.160 + public Object getValue() throws IllegalAccessException, InvocationTargetException
33.161 + {
33.162 + return getFormat().getFrameSize();
33.163 + }
33.164 +
33.165 + public String getName() {
33.166 + return NbBundle.getMessage(WavDataNode.class, "LBL_FrameSize");
33.167 + }
33.168 + }
33.169 +
33.170 + private class SampleSize extends AudioFormatProperty
33.171 + {
33.172 + public SampleSize(AudioFormat f)
33.173 + {
33.174 + super(f, Integer.class);
33.175 + }
33.176 +
33.177 + public Object getValue() throws IllegalAccessException, InvocationTargetException
33.178 + {
33.179 + return getFormat().getSampleSizeInBits();
33.180 + }
33.181 +
33.182 + public String getName() {
33.183 + return NbBundle.getMessage(WavDataNode.class, "LBL_SampleSize");
33.184 + }
33.185 + }
33.186 +
33.187 + private class Endian extends AudioFormatProperty
33.188 + {
33.189 + public Endian(AudioFormat f)
33.190 + {
33.191 + super(f, String.class);
33.192 + }
33.193 +
33.194 + public Object getValue() throws IllegalAccessException, InvocationTargetException
33.195 + {
33.196 + return getFormat().isBigEndian() ?
33.197 + NbBundle.getMessage(WavDataNode.class, "LBL_BigEndian") :
33.198 + NbBundle.getMessage(WavDataNode.class, "LBL_LittleEndian");
33.199 + }
33.200 +
33.201 + public String getName() {
33.202 + return NbBundle.getMessage(WavDataNode.class, "LBL_Endian");
33.203 + }
33.204 + }
33.205 +
33.206 +}
34.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
34.2 +++ b/platform/samples/AudioStation/wavsupport/src/org/foo/wavsupport/WavDataObject.java Thu Nov 02 01:01:27 2006 +0000
34.3 @@ -0,0 +1,190 @@
34.4 +/*
34.5 + * The contents of this file are subject to the terms of the Common Development
34.6 + * and Distribution License (the License). You may not use this file except in
34.7 + * compliance with the License.
34.8 + *
34.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
34.10 + * or http://www.netbeans.org/cddl.txt.
34.11 + *
34.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
34.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
34.14 + * If applicable, add the following below the CDDL Header, with the fields
34.15 + * enclosed by brackets [] replaced by your own identifying information:
34.16 + * "Portions Copyrighted [year] [name of copyright owner]"
34.17 + */
34.18 +package org.foo.wavsupport;
34.19 +
34.20 +import java.awt.event.ActionEvent;
34.21 +import java.io.File;
34.22 +import java.io.IOException;
34.23 +import javax.sound.sampled.AudioFormat;
34.24 +import javax.swing.AbstractAction;
34.25 +import org.foo.wavsupport.api.*;
34.26 +import org.foo.wavutils.WrappedAudioInputStream;
34.27 +import org.netbeans.core.spi.multiview.CloseOperationState;
34.28 +import org.netbeans.core.spi.multiview.MultiViewFactory;
34.29 +import org.openide.DialogDisplayer;
34.30 +import org.openide.ErrorManager;
34.31 +import org.openide.NotifyDescriptor;
34.32 +import org.openide.cookies.CloseCookie;
34.33 +import org.openide.cookies.SaveCookie;
34.34 +import org.openide.filesystems.FileObject;
34.35 +import org.openide.filesystems.FileUtil;
34.36 +import org.openide.loaders.DataObjectExistsException;
34.37 +import org.openide.loaders.MultiDataObject;
34.38 +import org.openide.nodes.Node;
34.39 +import org.openide.util.HelpCtx;
34.40 +import org.openide.util.actions.NodeAction;
34.41 +
34.42 +
34.43 +public class WavDataObject extends MultiDataObject implements WavCookie {
34.44 +
34.45 + private final SaveCookie saveCookie;
34.46 +
34.47 + /** The actual audio data */
34.48 + private transient WrappedAudioInputStream audioStream;
34.49 +
34.50 + public WavDataObject(FileObject pf, WavDataLoader loader) throws DataObjectExistsException, IOException {
34.51 + super(pf, loader);
34.52 + saveCookie = new WavSaveCookie(this);
34.53 + getCookieSet().add(new WavOpenSupport(getPrimaryEntry()));
34.54 + }
34.55 +
34.56 + protected Node createNodeDelegate() {
34.57 + return new WavDataNode(this);
34.58 + }
34.59 +
34.60 + public void setModified(boolean modified)
34.61 + {
34.62 + super.setModified(modified);
34.63 + if (modified)
34.64 + {
34.65 + addSaveCookie();
34.66 + }
34.67 + else
34.68 + {
34.69 + removeSaveCookie();
34.70 + }
34.71 + }
34.72 +
34.73 + public AudioFormat getAudioFormat()
34.74 + {
34.75 + return getAudioInputStream().getFormat();
34.76 + }
34.77 +
34.78 + public WrappedAudioInputStream getAudioInputStream()
34.79 + {
34.80 + if( audioStream == null )
34.81 + {
34.82 + FileObject promptFO = getPrimaryFile();
34.83 + File promptFile = FileUtil.toFile(promptFO);
34.84 + try
34.85 + {
34.86 + audioStream = WrappedAudioInputStream.createFromFile(promptFile);
34.87 + }
34.88 + catch (Exception ex)
34.89 + {
34.90 + NotifyDescriptor nd = new NotifyDescriptor.Message(
34.91 + "Can't get audio stream for " + getName()
34.92 + + " because " + ex.toString());
34.93 + DialogDisplayer.getDefault().notify(nd);
34.94 + }
34.95 + }
34.96 + return audioStream;
34.97 + }
34.98 +
34.99 + /**
34.100 + * @param is The AudioInputStream for this prompt, or null to revert to disk.
34.101 + */
34.102 + public void setAudioInputStream( WrappedAudioInputStream is )
34.103 + {
34.104 + final WrappedAudioInputStream oldStream = audioStream;
34.105 + audioStream = is;
34.106 + // If the audio input stream is not null, the wav file is modified.
34.107 + setModified(is != null);
34.108 + firePropertyChange(PROP_WAVEFORM, oldStream, is);
34.109 + }
34.110 +
34.111 + private void addSaveCookie()
34.112 + {
34.113 + if( getCookie( SaveCookie.class ) == null ) {
34.114 + getCookieSet().add( saveCookie );
34.115 + }
34.116 + }
34.117 +
34.118 + private void removeSaveCookie()
34.119 + {
34.120 + SaveCookie save = (SaveCookie) getCookie( SaveCookie.class );
34.121 + if( save != null ) {
34.122 + getCookieSet().remove( save );
34.123 + }
34.124 + }
34.125 +
34.126 + public static CloseOperationState createCloseOperationState()
34.127 + {
34.128 + return MultiViewFactory.createUnsafeCloseState(
34.129 + "File Not Saved", new ProceedAction(), new DiscardAction());
34.130 + }
34.131 +
34.132 + private static class ProceedAction extends NodeAction
34.133 + {
34.134 + protected void performAction(Node[] node) {
34.135 + try
34.136 + {
34.137 + if (node != null && node.length > 0)
34.138 + {
34.139 + SaveCookie sc = (SaveCookie)node[0].getCookie(SaveCookie.class);
34.140 + sc.save();
34.141 + }
34.142 + }
34.143 + catch(IOException ex)
34.144 + {
34.145 + ErrorManager.getDefault().notify(ex);
34.146 + }
34.147 + }
34.148 +
34.149 + protected boolean enable(Node[] node) {
34.150 + return true;
34.151 + }
34.152 +
34.153 + public String getName() {
34.154 + return "CloseHandler";
34.155 + }
34.156 +
34.157 + public HelpCtx getHelpCtx() {
34.158 + return null;
34.159 + }
34.160 + }
34.161 +
34.162 + private static class DiscardAction extends NodeAction
34.163 + {
34.164 + protected void performAction(Node[] node) {
34.165 + if (node != null && node.length > 0)
34.166 + {
34.167 + try
34.168 + {
34.169 + SaveCookie sc = (SaveCookie)node[0].getCookie(SaveCookie.class);
34.170 + sc.save();
34.171 + }
34.172 + catch(IOException ex)
34.173 + {
34.174 + CloseCookie c = (CloseCookie)node[0].getCookie(CloseCookie.class);
34.175 + c.close();
34.176 + }
34.177 + }
34.178 + }
34.179 +
34.180 + protected boolean enable(Node[] node) {
34.181 + return true;
34.182 + }
34.183 +
34.184 + public String getName() {
34.185 + return "Discard";
34.186 + }
34.187 +
34.188 + public HelpCtx getHelpCtx() {
34.189 + return null;
34.190 + }
34.191 + }
34.192 +
34.193 +}
35.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
35.2 +++ b/platform/samples/AudioStation/wavsupport/src/org/foo/wavsupport/WavOpenSupport.java Thu Nov 02 01:01:27 2006 +0000
35.3 @@ -0,0 +1,125 @@
35.4 +/*
35.5 + * The contents of this file are subject to the terms of the Common Development
35.6 + * and Distribution License (the License). You may not use this file except in
35.7 + * compliance with the License.
35.8 + *
35.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
35.10 + * or http://www.netbeans.org/cddl.txt.
35.11 + *
35.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
35.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
35.14 + * If applicable, add the following below the CDDL Header, with the fields
35.15 + * enclosed by brackets [] replaced by your own identifying information:
35.16 + * "Portions Copyrighted [year] [name of copyright owner]"
35.17 + */
35.18 +
35.19 +
35.20 +package org.foo.wavsupport;
35.21 +
35.22 +import java.awt.event.ActionEvent;
35.23 +import java.io.IOException;
35.24 +import java.io.Serializable;
35.25 +import java.util.ArrayList;
35.26 +import java.util.List;
35.27 +import javax.swing.AbstractAction;
35.28 +import org.foo.wavsupport.WavDataObject;
35.29 +import org.foo.wavsupport.api.WavViewDescriptor;
35.30 +import org.foo.wavsupport.ui.WavPanelMultiViewDescriptor;
35.31 +import org.netbeans.core.spi.multiview.CloseOperationHandler;
35.32 +import org.netbeans.core.spi.multiview.CloseOperationState;
35.33 +import org.netbeans.core.spi.multiview.MultiViewFactory;
35.34 +import org.openide.DialogDisplayer;
35.35 +import org.openide.ErrorManager;
35.36 +import org.openide.NotifyDescriptor;
35.37 +import org.openide.cookies.CloseCookie;
35.38 +import org.openide.cookies.OpenCookie;
35.39 +import org.openide.loaders.MultiDataObject;
35.40 +import org.openide.loaders.OpenSupport;
35.41 +import org.openide.util.Lookup;
35.42 +import org.openide.windows.CloneableTopComponent;
35.43 +
35.44 +/**
35.45 + *
35.46 + * @author runger
35.47 + */
35.48 +public class WavOpenSupport extends OpenSupport implements OpenCookie, CloseCookie
35.49 +{
35.50 + public WavOpenSupport(MultiDataObject.Entry entry)
35.51 + {
35.52 + super(entry);
35.53 + }
35.54 +
35.55 +
35.56 + protected CloneableTopComponent createCloneableTopComponent()
35.57 + {
35.58 + // get all instances of views for the multiview window
35.59 +
35.60 + WavViewDescriptor main = new WavPanelMultiViewDescriptor();
35.61 +
35.62 + List<WavViewDescriptor> all = new ArrayList<WavViewDescriptor>();
35.63 + all.add(main);
35.64 +
35.65 + Lookup.Template template = new Lookup.Template(WavViewDescriptor.class);
35.66 + Lookup.Result result = Lookup.getDefault().lookup(template);
35.67 + for (Object wvd : result.allInstances())
35.68 + {
35.69 + all.add((WavViewDescriptor)wvd);
35.70 + }
35.71 +
35.72 + // initialize all the views with data
35.73 +
35.74 + WavDataObject dobj = (WavDataObject)entry.getDataObject();
35.75 +
35.76 + for (WavViewDescriptor wvd : all)
35.77 + {
35.78 + wvd.setWavDataObject(dobj);
35.79 + }
35.80 +
35.81 + // create the multiview
35.82 +
35.83 + WavViewDescriptor[] allArray = new WavViewDescriptor[all.size()];
35.84 + all.toArray(allArray);
35.85 +
35.86 + CloneableTopComponent tc = MultiViewFactory.createCloneableMultiView(
35.87 + allArray, main, new CloseHandler());
35.88 +
35.89 + tc.setDisplayName(dobj.getName());
35.90 +
35.91 + return tc;
35.92 + }
35.93 +
35.94 + private static class CloseHandler implements CloseOperationHandler, Serializable
35.95 + {
35.96 + private static final long serialVersionUID = 47L;
35.97 + public boolean resolveCloseOperation(CloseOperationState[] elements)
35.98 + {
35.99 + NotifyDescriptor nd = new NotifyDescriptor.Confirmation(
35.100 + "Save before closing?");
35.101 + DialogDisplayer.getDefault().notify(nd);
35.102 +
35.103 + if (nd.getValue().equals(NotifyDescriptor.YES_OPTION))
35.104 + {
35.105 + for (CloseOperationState element : elements)
35.106 + {
35.107 + element.getProceedAction().actionPerformed(
35.108 + new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "xxx"));
35.109 + }
35.110 + return true;
35.111 + }
35.112 + else if (nd.getValue().equals(NotifyDescriptor.NO_OPTION))
35.113 + {
35.114 + for (CloseOperationState element : elements)
35.115 + {
35.116 + element.getDiscardAction().actionPerformed(
35.117 + new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "xxx"));
35.118 + }
35.119 + return true;
35.120 + }
35.121 + else
35.122 + {
35.123 + // Cancel
35.124 + return false;
35.125 + }
35.126 + }
35.127 + }
35.128 +}
36.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
36.2 +++ b/platform/samples/AudioStation/wavsupport/src/org/foo/wavsupport/WavResolver.xml Thu Nov 02 01:01:27 2006 +0000
36.3 @@ -0,0 +1,8 @@
36.4 +<?xml version="1.0" encoding="UTF-8"?>
36.5 +<!DOCTYPE MIME-resolver PUBLIC "-//NetBeans//DTD MIME Resolver 1.0//EN" "http://www.netbeans.org/dtds/mime-resolver-1_0.dtd">
36.6 +<MIME-resolver>
36.7 + <file>
36.8 + <ext name="wav"/>
36.9 + <resolver mime="audio/wav"/>
36.10 + </file>
36.11 +</MIME-resolver>
37.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
37.2 +++ b/platform/samples/AudioStation/wavsupport/src/org/foo/wavsupport/WavSaveCookie.java Thu Nov 02 01:01:27 2006 +0000
37.3 @@ -0,0 +1,58 @@
37.4 +/*
37.5 + * The contents of this file are subject to the terms of the Common Development
37.6 + * and Distribution License (the License). You may not use this file except in
37.7 + * compliance with the License.
37.8 + *
37.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
37.10 + * or http://www.netbeans.org/cddl.txt.
37.11 + *
37.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
37.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
37.14 + * If applicable, add the following below the CDDL Header, with the fields
37.15 + * enclosed by brackets [] replaced by your own identifying information:
37.16 + * "Portions Copyrighted [year] [name of copyright owner]"
37.17 + */
37.18 +
37.19 +package org.foo.wavsupport;
37.20 +
37.21 +import java.io.File;
37.22 +import java.io.IOException;
37.23 +import javax.sound.sampled.AudioFileFormat;
37.24 +import org.foo.wavsupport.WavDataObject;
37.25 +import org.foo.wavutils.Formats;
37.26 +import org.foo.wavutils.WrappedAudioInputStream;
37.27 +import org.openide.cookies.SaveCookie;
37.28 +import org.openide.filesystems.FileUtil;
37.29 +
37.30 +/**
37.31 + *
37.32 + * @author runger
37.33 + */
37.34 +public class WavSaveCookie implements SaveCookie {
37.35 +
37.36 + private WavDataObject wav;
37.37 +
37.38 + public WavSaveCookie(WavDataObject wav)
37.39 + {
37.40 + this.wav = wav;
37.41 + }
37.42 +
37.43 + public void save() throws IOException {
37.44 + if (!wav.isModified())
37.45 + return;
37.46 +
37.47 + // get the linear PCM data
37.48 + WrappedAudioInputStream pcmStream = wav.getAudioInputStream();
37.49 +
37.50 + if (pcmStream != null)
37.51 + {
37.52 + File wavFile = FileUtil.toFile(wav.getPrimaryFile());
37.53 +
37.54 + // write out to mu-law format
37.55 + pcmStream.toFile(wavFile,
37.56 + Formats.ULAW_FORMAT,
37.57 + AudioFileFormat.Type.WAVE);
37.58 + }
37.59 + wav.setModified(false);
37.60 + }
37.61 +}
38.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
38.2 +++ b/platform/samples/AudioStation/wavsupport/src/org/foo/wavsupport/api/WavCookie.java Thu Nov 02 01:01:27 2006 +0000
38.3 @@ -0,0 +1,41 @@
38.4 +/*
38.5 + * The contents of this file are subject to the terms of the Common Development
38.6 + * and Distribution License (the License). You may not use this file except in
38.7 + * compliance with the License.
38.8 + *
38.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
38.10 + * or http://www.netbeans.org/cddl.txt.
38.11 + *
38.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
38.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
38.14 + * If applicable, add the following below the CDDL Header, with the fields
38.15 + * enclosed by brackets [] replaced by your own identifying information:
38.16 + * "Portions Copyrighted [year] [name of copyright owner]"
38.17 + */
38.18 +
38.19 +
38.20 +package org.foo.wavsupport.api;
38.21 +
38.22 +import java.beans.PropertyChangeListener;
38.23 +import javax.sound.sampled.AudioFormat;
38.24 +import org.foo.wavsupport.WavDataObject;
38.25 +import org.foo.wavutils.WrappedAudioInputStream;
38.26 +import org.netbeans.core.spi.multiview.CloseOperationState;
38.27 +
38.28 +/**
38.29 + *
38.30 + * @author runger
38.31 + */
38.32 +public interface WavCookie {
38.33 + public static final CloseOperationState CLOSE_OPERATION_STATE = WavDataObject.createCloseOperationState();
38.34 + public static final String PROP_WAVEFORM = "waveform";
38.35 +
38.36 + AudioFormat getAudioFormat();
38.37 +
38.38 + WrappedAudioInputStream getAudioInputStream();
38.39 +
38.40 + void setAudioInputStream( WrappedAudioInputStream is );
38.41 +
38.42 + void addPropertyChangeListener(PropertyChangeListener l);
38.43 + void removePropertyChangeListener(PropertyChangeListener l);
38.44 +}
39.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
39.2 +++ b/platform/samples/AudioStation/wavsupport/src/org/foo/wavsupport/api/WavViewDescriptor.java Thu Nov 02 01:01:27 2006 +0000
39.3 @@ -0,0 +1,29 @@
39.4 +/*
39.5 + * The contents of this file are subject to the terms of the Common Development
39.6 + * and Distribution License (the License). You may not use this file except in
39.7 + * compliance with the License.
39.8 + *
39.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
39.10 + * or http://www.netbeans.org/cddl.txt.
39.11 + *
39.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
39.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
39.14 + * If applicable, add the following below the CDDL Header, with the fields
39.15 + * enclosed by brackets [] replaced by your own identifying information:
39.16 + * "Portions Copyrighted [year] [name of copyright owner]"
39.17 + */
39.18 +
39.19 +
39.20 +package org.foo.wavsupport.api;
39.21 +
39.22 +import java.io.Serializable;
39.23 +import org.netbeans.core.spi.multiview.MultiViewDescription;
39.24 +import org.openide.loaders.DataObject;
39.25 +
39.26 +/**
39.27 + *
39.28 + * @author runger
39.29 + */
39.30 +public interface WavViewDescriptor extends MultiViewDescription, Serializable {
39.31 + void setWavDataObject(DataObject dobj);
39.32 +}
40.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
40.2 +++ b/platform/samples/AudioStation/wavsupport/src/org/foo/wavsupport/favoritesWstcref.xml Thu Nov 02 01:01:27 2006 +0000
40.3 @@ -0,0 +1,11 @@
40.4 +<?xml version="1.0" encoding="UTF-8"?>
40.5 +
40.6 +<!DOCTYPE tc-ref PUBLIC
40.7 + "-//NetBeans//DTD Top Component in Mode Properties 2.0//EN"
40.8 + "http://www.netbeans.org/dtds/tc-ref2_0.dtd">
40.9 +
40.10 +<tc-ref version="2.0">
40.11 + <module name="org.netbeans.modules.favorites/1" spec="1.1" />
40.12 + <tc-id id="favorites" />
40.13 + <state opened="true" />
40.14 +</tc-ref>
41.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
41.2 +++ b/platform/samples/AudioStation/wavsupport/src/org/foo/wavsupport/layer.xml Thu Nov 02 01:01:27 2006 +0000
41.3 @@ -0,0 +1,67 @@
41.4 +<?xml version="1.0" encoding="UTF-8"?>
41.5 +<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
41.6 +<filesystem>
41.7 + <folder name="Loaders">
41.8 + <folder name="audio">
41.9 + <folder name="wav">
41.10 + <folder name="Actions">
41.11 + <file name="org-openide-actions-OpenAction.instance"/>
41.12 + <attr name="org-openide-actions-OpenAction.instance/org-openide-actions-FileSystemAction.instance" boolvalue="true"/>
41.13 + <file name="org-openide-actions-FileSystemAction.instance"/>
41.14 + <attr name="org-openide-actions-FileSystemAction.instance/sep-1.instance" boolvalue="true"/>
41.15 + <file name="sep-1.instance">
41.16 + <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
41.17 + </file>
41.18 + <attr name="sep-1.instance/org-openide-actions-CutAction.instance" boolvalue="true"/>
41.19 + <file name="org-openide-actions-CutAction.instance"/>
41.20 + <attr name="org-openide-actions-CutAction.instance/org-openide-actions-CopyAction.instance" boolvalue="true"/>
41.21 + <file name="org-openide-actions-CopyAction.instance"/>
41.22 + <attr name="org-openide-actions-CopyAction.instance/sep-2.instance" boolvalue="true"/>
41.23 + <file name="sep-2.instance">
41.24 + <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
41.25 + </file>
41.26 + <attr name="sep-2.instance/org-openide-actions-DeleteAction.instance" boolvalue="true"/>
41.27 + <file name="org-openide-actions-DeleteAction.instance"/>
41.28 + <attr name="org-openide-actions-DeleteAction.instance/org-openide-actions-RenameAction.instance" boolvalue="true"/>
41.29 + <file name="org-openide-actions-RenameAction.instance"/>
41.30 + <attr name="org-openide-actions-RenameAction.instance/sep-3.instance" boolvalue="true"/>
41.31 + <file name="sep-3.instance">
41.32 + <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
41.33 + </file>
41.34 + <attr name="sep-3.instance/org-openide-actions-SaveAsTemplateAction.instance" boolvalue="true"/>
41.35 + <file name="org-openide-actions-SaveAsTemplateAction.instance"/>
41.36 + <attr name="org-openide-actions-SaveAsTemplateAction.instance/sep-4.instance" boolvalue="true"/>
41.37 + <file name="sep-4.instance">
41.38 + <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
41.39 + </file>
41.40 + <attr name="sep-4.instance/org-openide-actions-ToolsAction.instance" boolvalue="true"/>
41.41 + <file name="org-openide-actions-ToolsAction.instance"/>
41.42 + <attr name="org-openide-actions-ToolsAction.instance/org-openide-actions-PropertiesAction.instance" boolvalue="true"/>
41.43 + <file name="org-openide-actions-PropertiesAction.instance"/>
41.44 + </folder>
41.45 + </folder>
41.46 + </folder>
41.47 + </folder>
41.48 + <folder name="Services">
41.49 + <folder name="MIMEResolver">
41.50 + <file name="WavResolver.xml" url="WavResolver.xml">
41.51 + <attr name="SystemFileSystem.localizingBundle" stringvalue="org.foo.wavsupport.Bundle"/>
41.52 + </file>
41.53 + </folder>
41.54 + </folder>
41.55 + <folder name="Templates">
41.56 + <folder name="Other">
41.57 + <file name="WavTemplate.wav" url="WavTemplate.wav">
41.58 + <attr name="SystemFileSystem.localizingBundle" stringvalue="org.foo.wavsupport.Bundle"/>
41.59 + <attr name="template" boolvalue="true"/>
41.60 + </file>
41.61 + </folder>
41.62 + </folder>
41.63 + <folder name="Windows2">
41.64 + <folder name="Modes">
41.65 + <folder name="explorer">
41.66 + <file name="favorites.wstcref" url="favoritesWstcref.xml"/>
41.67 + </folder>
41.68 + </folder>
41.69 + </folder>
41.70 +</filesystem>
42.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
42.2 +++ b/platform/samples/AudioStation/wavsupport/src/org/foo/wavsupport/ui/Bundle.properties Thu Nov 02 01:01:27 2006 +0000
42.3 @@ -0,0 +1,63 @@
42.4 +
42.5 +WavPanel.cropButton.toolTipText=Crop
42.6 +
42.7 +
42.8 +
42.9 +
42.10 +
42.11 +
42.12 +
42.13 +
42.14 +# Sample ResourceBundle properties file
42.15 +WavPanel.cropButton.text=
42.16 +
42.17 +WavPanel.playButton.toolTipText=Play
42.18 +
42.19 +
42.20 +
42.21 +
42.22 +
42.23 +
42.24 +
42.25 +# Sample ResourceBundle properties file
42.26 +WavPanel.playButton.text=
42.27 +
42.28 +WavPanel.revertButton.toolTipText=Revert to Saved
42.29 +
42.30 +
42.31 +
42.32 +
42.33 +
42.34 +
42.35 +
42.36 +
42.37 +# Sample ResourceBundle properties file
42.38 +WavPanel.revertButton.text=
42.39 +
42.40 +WavPanel.stopButton.toolTipText=Stop
42.41 +
42.42 +
42.43 +
42.44 +
42.45 +
42.46 +
42.47 +# Sample ResourceBundle properties file
42.48 +WavPanel.stopButton.text=
42.49 +
42.50 +WavPanel.pauseButton.toolTipText=Pause
42.51 +
42.52 +
42.53 +
42.54 +
42.55 +
42.56 +
42.57 +# Sample ResourceBundle properties file
42.58 +WavPanel.pauseButton.text=
42.59 +
42.60 +WavPanel.recordButton.toolTipText=Record
42.61 +
42.62 +
42.63 +
42.64 +
42.65 +# Sample ResourceBundle properties file
42.66 +WavPanel.recordButton.text=
43.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
43.2 +++ b/platform/samples/AudioStation/wavsupport/src/org/foo/wavsupport/ui/WavPanel.form Thu Nov 02 01:01:27 2006 +0000
43.3 @@ -0,0 +1,175 @@
43.4 +<?xml version="1.0" encoding="UTF-8" ?>
43.5 +
43.6 +<Form version="1.3" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
43.7 + <AuxValues>
43.8 + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
43.9 + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
43.10 + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
43.11 + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
43.12 + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
43.13 + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
43.14 + </AuxValues>
43.15 +
43.16 + <Layout>
43.17 + <DimensionLayout dim="0">
43.18 + <Group type="103" groupAlignment="0" attributes="0">
43.19 + <Component id="btnPanel" alignment="0" pref="396" max="32767" attributes="0"/>
43.20 + <Component id="samplingGraph" alignment="0" max="32767" attributes="0"/>
43.21 + </Group>
43.22 + </DimensionLayout>
43.23 + <DimensionLayout dim="1">
43.24 + <Group type="103" groupAlignment="0" attributes="0">
43.25 + <Group type="102" alignment="1" attributes="0">
43.26 + <Component id="samplingGraph" max="32767" attributes="0"/>
43.27 + <EmptySpace max="-2" attributes="0"/>
43.28 + <Component id="btnPanel" min="-2" pref="47" max="-2" attributes="0"/>
43.29 + </Group>
43.30 + </Group>
43.31 + </DimensionLayout>
43.32 + </Layout>
43.33 + <SubComponents>
43.34 + <Container class="javax.swing.JPanel" name="btnPanel">
43.35 +
43.36 + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
43.37 + <SubComponents>
43.38 + <Component class="javax.swing.JButton" name="recordButton">
43.39 + <Properties>
43.40 + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
43.41 + <Image iconType="3" name="/org/foo/wavutils/recordButton.gif"/>
43.42 + </Property>
43.43 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
43.44 + <ResourceString bundle="org/foo/wavsupport/ui/Bundle.properties" key="WavPanel.recordButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
43.45 + </Property>
43.46 + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
43.47 + <ResourceString bundle="org/foo/wavsupport/ui/Bundle.properties" key="WavPanel.recordButton.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
43.48 + </Property>
43.49 + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
43.50 + <Border info="null"/>
43.51 + </Property>
43.52 + <Property name="borderPainted" type="boolean" value="false"/>
43.53 + </Properties>
43.54 + <Events>
43.55 + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="recordButtonActionPerformed"/>
43.56 + </Events>
43.57 + </Component>
43.58 + <Component class="javax.swing.JButton" name="playButton">
43.59 + <Properties>
43.60 + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
43.61 + <Image iconType="3" name="/org/foo/wavutils/playButton.gif"/>
43.62 + </Property>
43.63 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
43.64 + <ResourceString bundle="org/foo/wavsupport/ui/Bundle.properties" key="WavPanel.playButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
43.65 + </Property>
43.66 + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
43.67 + <ResourceString bundle="org/foo/wavsupport/ui/Bundle.properties" key="WavPanel.playButton.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
43.68 + </Property>
43.69 + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
43.70 + <Border info="null"/>
43.71 + </Property>
43.72 + <Property name="borderPainted" type="boolean" value="false"/>
43.73 + </Properties>
43.74 + <Events>
43.75 + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="playButtonActionPerformed"/>
43.76 + </Events>
43.77 + </Component>
43.78 + <Component class="javax.swing.JButton" name="pauseButton">
43.79 + <Properties>
43.80 + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
43.81 + <Image iconType="3" name="/org/foo/wavutils/pauseButton.gif"/>
43.82 + </Property>
43.83 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
43.84 + <ResourceString bundle="org/foo/wavsupport/ui/Bundle.properties" key="WavPanel.pauseButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
43.85 + </Property>
43.86 + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
43.87 + <ResourceString bundle="org/foo/wavsupport/ui/Bundle.properties" key="WavPanel.pauseButton.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
43.88 + </Property>
43.89 + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
43.90 + <Border info="null"/>
43.91 + </Property>
43.92 + <Property name="borderPainted" type="boolean" value="false"/>
43.93 + <Property name="enabled" type="boolean" value="false"/>
43.94 + </Properties>
43.95 + <Events>
43.96 + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="pauseButtonActionPerformed"/>
43.97 + </Events>
43.98 + </Component>
43.99 + <Component class="javax.swing.JButton" name="stopButton">
43.100 + <Properties>
43.101 + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
43.102 + <Image iconType="3" name="/org/foo/wavutils/stopButton.gif"/>
43.103 + </Property>
43.104 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
43.105 + <ResourceString bundle="org/foo/wavsupport/ui/Bundle.properties" key="WavPanel.stopButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
43.106 + </Property>
43.107 + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
43.108 + <ResourceString bundle="org/foo/wavsupport/ui/Bundle.properties" key="WavPanel.stopButton.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
43.109 + </Property>
43.110 + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
43.111 + <Border info="null"/>
43.112 + </Property>
43.113 + <Property name="borderPainted" type="boolean" value="false"/>
43.114 + <Property name="enabled" type="boolean" value="false"/>
43.115 + </Properties>
43.116 + <Events>
43.117 + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="stopButtonActionPerformed"/>
43.118 + </Events>
43.119 + </Component>
43.120 + <Component class="javax.swing.JButton" name="cropButton">
43.121 + <Properties>
43.122 + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
43.123 + <Image iconType="3" name="/org/foo/wavutils/crop.gif"/>
43.124 + </Property>
43.125 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
43.126 + <ResourceString bundle="org/foo/wavsupport/ui/Bundle.properties" key="WavPanel.cropButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
43.127 + </Property>
43.128 + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
43.129 + <ResourceString bundle="org/foo/wavsupport/ui/Bundle.properties" key="WavPanel.cropButton.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
43.130 + </Property>
43.131 + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
43.132 + <Border info="null"/>
43.133 + </Property>
43.134 + <Property name="borderPainted" type="boolean" value="false"/>
43.135 + </Properties>
43.136 + <Events>
43.137 + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cropButtonActionPerformed"/>
43.138 + </Events>
43.139 + </Component>
43.140 + <Component class="javax.swing.JButton" name="revertButton">
43.141 + <Properties>
43.142 + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
43.143 + <Image iconType="3" name="/org/foo/wavutils/revert.gif"/>
43.144 + </Property>
43.145 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
43.146 + <ResourceString bundle="org/foo/wavsupport/ui/Bundle.properties" key="WavPanel.revertButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
43.147 + </Property>
43.148 + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
43.149 + <ResourceString bundle="org/foo/wavsupport/ui/Bundle.properties" key="WavPanel.revertButton.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
43.150 + </Property>
43.151 + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
43.152 + <Border info="null"/>
43.153 + </Property>
43.154 + <Property name="borderPainted" type="boolean" value="false"/>
43.155 + </Properties>
43.156 + <Events>
43.157 + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="revertButtonActionPerformed"/>
43.158 + </Events>
43.159 + </Component>
43.160 + </SubComponents>
43.161 + </Container>
43.162 + <Container class="org.foo.wavutils.SamplingGraph" name="samplingGraph">
43.163 +
43.164 + <Layout>
43.165 + <DimensionLayout dim="0">
43.166 + <Group type="103" groupAlignment="0" attributes="0">
43.167 + <EmptySpace min="0" pref="396" max="32767" attributes="0"/>
43.168 + </Group>
43.169 + </DimensionLayout>
43.170 + <DimensionLayout dim="1">
43.171 + <Group type="103" groupAlignment="0" attributes="0">
43.172 + <EmptySpace min="0" pref="202" max="32767" attributes="0"/>
43.173 + </Group>
43.174 + </DimensionLayout>
43.175 + </Layout>
43.176 + </Container>
43.177 + </SubComponents>
43.178 +</Form>
44.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
44.2 +++ b/platform/samples/AudioStation/wavsupport/src/org/foo/wavsupport/ui/WavPanel.java Thu Nov 02 01:01:27 2006 +0000
44.3 @@ -0,0 +1,432 @@
44.4 +/*
44.5 + * The contents of this file are subject to the terms of the Common Development
44.6 + * and Distribution License (the License). You may not use this file except in
44.7 + * compliance with the License.
44.8 + *
44.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
44.10 + * or http://www.netbeans.org/cddl.txt.
44.11 + *
44.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
44.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
44.14 + * If applicable, add the following below the CDDL Header, with the fields
44.15 + * enclosed by brackets [] replaced by your own identifying information:
44.16 + * "Portions Copyrighted [year] [name of copyright owner]"
44.17 + */
44.18 +
44.19 +package org.foo.wavsupport.ui;
44.20 +
44.21 +import java.beans.PropertyChangeEvent;
44.22 +import java.beans.PropertyChangeListener;
44.23 +import java.io.IOException;
44.24 +import javax.swing.SwingUtilities;
44.25 +import org.foo.wavsupport.WavDataObject;
44.26 +import org.foo.wavsupport.api.WavCookie;
44.27 +import org.foo.wavutils.AudioUI;
44.28 +import org.foo.wavutils.AudioUI.Selection;
44.29 +import org.foo.wavutils.Player;
44.30 +import org.foo.wavutils.Recorder;
44.31 +import org.foo.wavutils.SamplingGraph;
44.32 +import org.foo.wavutils.WrappedAudioInputStream;
44.33 +import org.openide.DialogDisplayer;
44.34 +import org.openide.NotifyDescriptor;
44.35 +import org.openide.loaders.DataObject;
44.36 +import org.openide.util.Task;
44.37 +
44.38 +/**
44.39 + *
44.40 + * @author runger
44.41 + */
44.42 +public class WavPanel extends javax.swing.JPanel implements AudioUI {
44.43 + private DataObject wav;
44.44 + private Player player;
44.45 + private Recorder recorder;
44.46 +
44.47 + private WavFileModificationListener fileListener = new WavFileModificationListener();
44.48 + private WavDataModificationListener dataListener = new WavDataModificationListener();
44.49 +
44.50 + public WavPanel(DataObject dobj)
44.51 + {
44.52 + initComponents();
44.53 + initialize(dobj);
44.54 + }
44.55 +
44.56 + DataObject getWavDataObject()
44.57 + {
44.58 + return wav;
44.59 + }
44.60 +
44.61 + public void setAudioInputStream(WrappedAudioInputStream is)
44.62 + {
44.63 + WavCookie c = (WavCookie)wav.getCookie(WavCookie.class);
44.64 + assert(c != null);
44.65 + c.setAudioInputStream(is);
44.66 + }
44.67 +
44.68 + public WrappedAudioInputStream getAudioInputStream() {
44.69 + WavCookie c = (WavCookie)wav.getCookie(WavCookie.class);
44.70 + assert (c != null);
44.71 + return c.getAudioInputStream();
44.72 + }
44.73 +
44.74 + public SamplingGraph getSamplingGraph()
44.75 + {
44.76 + return samplingGraph;
44.77 + }
44.78 +
44.79 + /** Call only when initializing: in constructor or readExternal() */
44.80 + private void initialize(DataObject wavDO)
44.81 + {
44.82 + assert SwingUtilities.isEventDispatchThread() :
44.83 + "Attempting to populate prompt editor from outside the AWT event thread";
44.84 +
44.85 + player = new Player(this);
44.86 + recorder = new Recorder(this);
44.87 +
44.88 + wav = wavDO;
44.89 + wav.addPropertyChangeListener(fileListener);
44.90 +
44.91 + WavCookie c = (WavCookie)wav.getCookie(WavCookie.class);
44.92 + assert(c != null);
44.93 +
44.94 + c.addPropertyChangeListener(dataListener);
44.95 + WrappedAudioInputStream stream = c.getAudioInputStream();
44.96 +
44.97 + // force a PropertyChangeEvent for drawing the sample graph
44.98 + c.setAudioInputStream(null);
44.99 + c.setAudioInputStream(stream);
44.100 + wav.setModified(false);
44.101 +
44.102 + playButton.setEnabled(stream != null);
44.103 + }
44.104 +
44.105 + /**
44.106 + * Called when the Player finishes playing or the
44.107 + * Recorder finishes recording.
44.108 + */
44.109 + public void taskFinished( Task task )
44.110 + {
44.111 + playButton.setEnabled(true);
44.112 + recordButton.setEnabled(true);
44.113 + cropButton.setEnabled(true);
44.114 + stopButton.setEnabled(false);
44.115 + pauseButton.setEnabled(false);
44.116 + }
44.117 +
44.118 + public void setVisible(boolean visible) {
44.119 + super.setVisible(visible);
44.120 +
44.121 + if (!visible && wav != null)
44.122 + {
44.123 + if (samplingGraph.isRecording())
44.124 + {
44.125 + recorder.stop();
44.126 + samplingGraph.stop();
44.127 + samplingGraph.setRecording(false);
44.128 + wav.setModified(true);
44.129 + }
44.130 + }
44.131 + }
44.132 +
44.133 + /** This method is called from within the constructor to
44.134 + * initialize the form.
44.135 + * WARNING: Do NOT modify this code. The content of this method is
44.136 + * always regenerated by the Form Editor.
44.137 + */
44.138 + // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
44.139 + private void initComponents() {
44.140 + btnPanel = new javax.swing.JPanel();
44.141 + recordButton = new javax.swing.JButton();
44.142 + playButton = new javax.swing.JButton();
44.143 + pauseButton = new javax.swing.JButton();
44.144 + stopButton = new javax.swing.JButton();
44.145 + cropButton = new javax.swing.JButton();
44.146 + revertButton = new javax.swing.JButton();
44.147 + samplingGraph = new org.foo.wavutils.SamplingGraph();
44.148 +
44.149 + recordButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/foo/wavutils/recordButton.gif")));
44.150 + recordButton.setText(org.openide.util.NbBundle.getMessage(WavPanel.class, "WavPanel.recordButton.text"));
44.151 + recordButton.setToolTipText(org.openide.util.NbBundle.getMessage(WavPanel.class, "WavPanel.recordButton.toolTipText"));
44.152 + recordButton.setBorder(null);
44.153 + recordButton.setBorderPainted(false);
44.154 + recordButton.addActionListener(new java.awt.event.ActionListener() {
44.155 + public void actionPerformed(java.awt.event.ActionEvent evt) {
44.156 + recordButtonActionPerformed(evt);
44.157 + }
44.158 + });
44.159 +
44.160 + btnPanel.add(recordButton);
44.161 +
44.162 + playButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/foo/wavutils/playButton.gif")));
44.163 + playButton.setText(org.openide.util.NbBundle.getMessage(WavPanel.class, "WavPanel.playButton.text"));
44.164 + playButton.setToolTipText(org.openide.util.NbBundle.getMessage(WavPanel.class, "WavPanel.playButton.toolTipText"));
44.165 + playButton.setBorder(null);
44.166 + playButton.setBorderPainted(false);
44.167 + playButton.addActionListener(new java.awt.event.ActionListener() {
44.168 + public void actionPerformed(java.awt.event.ActionEvent evt) {
44.169 + playButtonActionPerformed(evt);
44.170 + }
44.171 + });
44.172 +
44.173 + btnPanel.add(playButton);
44.174 +
44.175 + pauseButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/foo/wavutils/pauseButton.gif")));
44.176 + pauseButton.setText(org.openide.util.NbBundle.getMessage(WavPanel.class, "WavPanel.pauseButton.text"));
44.177 + pauseButton.setToolTipText(org.openide.util.NbBundle.getMessage(WavPanel.class, "WavPanel.pauseButton.toolTipText"));
44.178 + pauseButton.setBorder(null);
44.179 + pauseButton.setBorderPainted(false);
44.180 + pauseButton.setEnabled(false);
44.181 + pauseButton.addActionListener(new java.awt.event.ActionListener() {
44.182 + public void actionPerformed(java.awt.event.ActionEvent evt) {
44.183 + pauseButtonActionPerformed(evt);
44.184 + }
44.185 + });
44.186 +
44.187 + btnPanel.add(pauseButton);
44.188 +
44.189 + stopButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/foo/wavutils/stopButton.gif")));
44.190 + stopButton.setText(org.openide.util.NbBundle.getMessage(WavPanel.class, "WavPanel.stopButton.text"));
44.191 + stopButton.setToolTipText(org.openide.util.NbBundle.getMessage(WavPanel.class, "WavPanel.stopButton.toolTipText"));
44.192 + stopButton.setBorder(null);
44.193 + stopButton.setBorderPainted(false);
44.194 + stopButton.setEnabled(false);
44.195 + stopButton.addActionListener(new java.awt.event.ActionListener() {
44.196 + public void actionPerformed(java.awt.event.ActionEvent evt) {
44.197 + stopButtonActionPerformed(evt);
44.198 + }
44.199 + });
44.200 +
44.201 + btnPanel.add(stopButton);
44.202 +
44.203 + cropButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/foo/wavutils/crop.gif")));
44.204 + cropButton.setText(org.openide.util.NbBundle.getMessage(WavPanel.class, "WavPanel.cropButton.text"));
44.205 + cropButton.setToolTipText(org.openide.util.NbBundle.getMessage(WavPanel.class, "WavPanel.cropButton.toolTipText"));
44.206 + cropButton.setBorder(null);
44.207 + cropButton.setBorderPainted(false);
44.208 + cropButton.addActionListener(new java.awt.event.ActionListener() {
44.209 + public void actionPerformed(java.awt.event.ActionEvent evt) {
44.210 + cropButtonActionPerformed(evt);
44.211 + }
44.212 + });
44.213 +
44.214 + btnPanel.add(cropButton);
44.215 +
44.216 + revertButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/foo/wavutils/revert.gif")));
44.217 + revertButton.setText(org.openide.util.NbBundle.getMessage(WavPanel.class, "WavPanel.revertButton.text"));
44.218 + revertButton.setToolTipText(org.openide.util.NbBundle.getMessage(WavPanel.class, "WavPanel.revertButton.toolTipText"));
44.219 + revertButton.setBorder(null);
44.220 + revertButton.setBorderPainted(false);
44.221 + revertButton.addActionListener(new java.awt.event.ActionListener() {
44.222 + public void actionPerformed(java.awt.event.ActionEvent evt) {
44.223 + revertButtonActionPerformed(evt);
44.224 + }
44.225 + });
44.226 +
44.227 + btnPanel.add(revertButton);
44.228 +
44.229 + javax.swing.GroupLayout samplingGraphLayout = new javax.swing.GroupLayout(samplingGraph);
44.230 + samplingGraph.setLayout(samplingGraphLayout);
44.231 + samplingGraphLayout.setHorizontalGroup(
44.232 + samplingGraphLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
44.233 + .addGap(0, 396, Short.MAX_VALUE)
44.234 + );
44.235 + samplingGraphLayout.setVerticalGroup(
44.236 + samplingGraphLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
44.237 + .addGap(0, 202, Short.MAX_VALUE)
44.238 + );
44.239 +
44.240 + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
44.241 + this.setLayout(layout);
44.242 + layout.setHorizontalGroup(
44.243 + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
44.244 + .addComponent(btnPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE)
44.245 + .addComponent(samplingGraph, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
44.246 + );
44.247 + layout.setVerticalGroup(
44.248 + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
44.249 + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
44.250 + .addComponent(samplingGraph, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
44.251 + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
44.252 + .addComponent(btnPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE))
44.253 + );
44.254 + }// </editor-fold>//GEN-END:initComponents
44.255 +
44.256 + private void revertButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_revertButtonActionPerformed
44.257 + setAudioInputStream(null);
44.258 + }//GEN-LAST:event_revertButtonActionPerformed
44.259 +
44.260 + private void cropButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cropButtonActionPerformed
44.261 + Selection curSelection = Selection.getSelection(this);
44.262 + WavCookie c = (WavCookie)wav.getCookie(WavCookie.class);
44.263 + assert(c != null);
44.264 + WrappedAudioInputStream pcmStream = c.getAudioInputStream();
44.265 +
44.266 + if( curSelection == null || pcmStream == null )
44.267 + {
44.268 + // nothing to crop
44.269 + NotifyDescriptor nd = new NotifyDescriptor.Message(
44.270 + "Nothing is selected to crop. Use the mouse to select a portion of the waveform by clicking the left mouse button and dragging.",
44.271 + NotifyDescriptor.INFORMATION_MESSAGE);
44.272 + DialogDisplayer.getDefault().notify(nd);
44.273 + return;
44.274 + }
44.275 +
44.276 + try
44.277 + {
44.278 + pcmStream.crop( curSelection.offset, curSelection.length );
44.279 +
44.280 + // it's the same stream instance, so force a PropretyChangeEvent
44.281 + // by setting to null first
44.282 + c.setAudioInputStream(null);
44.283 + c.setAudioInputStream(pcmStream);
44.284 + }
44.285 + catch( IOException ex )
44.286 + {
44.287 + NotifyDescriptor nd = new NotifyDescriptor.Message(
44.288 + "Error Cropping Prompt: " + ex);
44.289 + DialogDisplayer.getDefault().notify(nd);
44.290 + }
44.291 + }//GEN-LAST:event_cropButtonActionPerformed
44.292 +
44.293 + private void playButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_playButtonActionPerformed
44.294 + playButton.setEnabled(false);
44.295 + recordButton.setEnabled(false);
44.296 + cropButton.setEnabled(false);
44.297 + stopButton.setEnabled(true);
44.298 + pauseButton.setEnabled(true);
44.299 +
44.300 + player.start();
44.301 + samplingGraph.start();
44.302 + }//GEN-LAST:event_playButtonActionPerformed
44.303 +
44.304 + private void stopButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stopButtonActionPerformed
44.305 + try
44.306 + {
44.307 + if( samplingGraph.isRecording() )
44.308 + {
44.309 + recorder.stop();
44.310 + samplingGraph.stop();
44.311 + samplingGraph.setRecording(false);
44.312 + }
44.313 + else
44.314 + {
44.315 + player.stop();
44.316 + samplingGraph.stop();
44.317 + }
44.318 + }
44.319 + finally
44.320 + {
44.321 + playButton.setEnabled(true);
44.322 + recordButton.setEnabled(true);
44.323 + cropButton.setEnabled(true);
44.324 + stopButton.setEnabled(false);
44.325 + pauseButton.setEnabled(false);
44.326 + }
44.327 + }//GEN-LAST:event_stopButtonActionPerformed
44.328 +
44.329 + private void pauseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pauseButtonActionPerformed
44.330 + try
44.331 + {
44.332 + if( samplingGraph.isRecording() )
44.333 + {
44.334 + //TODO: support pause during record
44.335 + }
44.336 + else
44.337 + {
44.338 + player.pause();
44.339 + }
44.340 + }
44.341 + finally
44.342 + {
44.343 + playButton.setEnabled(false);
44.344 + recordButton.setEnabled(false);
44.345 + cropButton.setEnabled(false);
44.346 + stopButton.setEnabled(true);
44.347 + pauseButton.setEnabled(true);
44.348 + }
44.349 + }//GEN-LAST:event_pauseButtonActionPerformed
44.350 +
44.351 + private void recordButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_recordButtonActionPerformed
44.352 + if( !samplingGraph.isRecording() )
44.353 + {
44.354 + // start recording
44.355 + playButton.setEnabled(false);
44.356 + recordButton.setEnabled(true);
44.357 + cropButton.setEnabled(false);
44.358 + stopButton.setEnabled(true);
44.359 + pauseButton.setEnabled(true);
44.360 +
44.361 + samplingGraph.setRecording(true);
44.362 + wav.setModified(true);
44.363 +
44.364 + recorder.start();
44.365 + samplingGraph.start();
44.366 + }
44.367 + else
44.368 + {
44.369 + // stop recording
44.370 + stopButtonActionPerformed(evt);
44.371 + }
44.372 + }//GEN-LAST:event_recordButtonActionPerformed
44.373 +
44.374 + private class WavFileModificationListener implements PropertyChangeListener
44.375 + {
44.376 + public void propertyChange(PropertyChangeEvent pce)
44.377 + {
44.378 + String propertyName = pce.getPropertyName();
44.379 + if(DataObject.PROP_MODIFIED.equals(propertyName))
44.380 + {
44.381 + if(pce.getNewValue() == Boolean.TRUE)
44.382 + {
44.383 + // The prompt is modified by a record, crop, normalize, etc.
44.384 + playButton.setEnabled(true);
44.385 + revertButton.setEnabled(true);
44.386 + }
44.387 + else
44.388 + {
44.389 + // the prompt is unmodified by save or revert
44.390 + revertButton.setEnabled(false);
44.391 +
44.392 + WavCookie c = (WavCookie)wav.getCookie(WavCookie.class);
44.393 + assert(c != null);
44.394 + playButton.setEnabled(c.getAudioInputStream() != null);
44.395 + }
44.396 + }
44.397 + }
44.398 + }
44.399 +
44.400 + private class WavDataModificationListener implements PropertyChangeListener
44.401 + {
44.402 + public void propertyChange(PropertyChangeEvent pce)
44.403 + {
44.404 + String propertyName = pce.getPropertyName();
44.405 + if(WavCookie.PROP_WAVEFORM.equals(propertyName))
44.406 + {
44.407 + refreshGraphData();
44.408 + }
44.409 + }
44.410 + }
44.411 +
44.412 + private void refreshGraphData()
44.413 + {
44.414 + WrappedAudioInputStream wais = getAudioInputStream();
44.415 + SamplingGraph graph = getSamplingGraph();
44.416 + if (wais == null)
44.417 + graph.clearWaveForm();
44.418 + else
44.419 + graph.createWaveForm(wais);
44.420 + }
44.421 +
44.422 +
44.423 +
44.424 + // Variables declaration - do not modify//GEN-BEGIN:variables
44.425 + private javax.swing.JPanel btnPanel;
44.426 + private javax.swing.JButton cropButton;
44.427 + private javax.swing.JButton pauseButton;
44.428 + private javax.swing.JButton playButton;
44.429 + private javax.swing.JButton recordButton;
44.430 + private javax.swing.JButton revertButton;
44.431 + private org.foo.wavutils.SamplingGraph samplingGraph;
44.432 + private javax.swing.JButton stopButton;
44.433 + // End of variables declaration//GEN-END:variables
44.434 +
44.435 +}
45.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
45.2 +++ b/platform/samples/AudioStation/wavsupport/src/org/foo/wavsupport/ui/WavPanelMultiViewDescriptor.java Thu Nov 02 01:01:27 2006 +0000
45.3 @@ -0,0 +1,72 @@
45.4 +/*
45.5 + * The contents of this file are subject to the terms of the Common Development
45.6 + * and Distribution License (the License). You may not use this file except in
45.7 + * compliance with the License.
45.8 + *
45.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
45.10 + * or http://www.netbeans.org/cddl.txt.
45.11 + *
45.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
45.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
45.14 + * If applicable, add the following below the CDDL Header, with the fields
45.15 + * enclosed by brackets [] replaced by your own identifying information:
45.16 + * "Portions Copyrighted [year] [name of copyright owner]"
45.17 + */
45.18 +
45.19 +package org.foo.wavsupport.ui;
45.20 +
45.21 +import java.awt.Image;
45.22 +import java.io.IOException;
45.23 +import java.io.ObjectOutputStream;
45.24 +import java.io.Serializable;
45.25 +import org.foo.wavsupport.api.WavViewDescriptor;
45.26 +import org.netbeans.core.spi.multiview.MultiViewElement;
45.27 +import org.openide.loaders.DataObject;
45.28 +import org.openide.util.HelpCtx;
45.29 +import org.openide.util.Utilities;
45.30 +import org.openide.windows.TopComponent;
45.31 +
45.32 +/**
45.33 + *
45.34 + * @author runger
45.35 + */
45.36 +public class WavPanelMultiViewDescriptor implements WavViewDescriptor, Serializable {
45.37 + private static final long serialVersionUID = 2L;
45.38 +
45.39 + public static Image ICON = Utilities.loadImage("org/foo/wavutils/sampleGraph.gif");
45.40 +
45.41 + private DataObject dobj;
45.42 +
45.43 + public int getPersistenceType() {
45.44 + return TopComponent.PERSISTENCE_ALWAYS;
45.45 + }
45.46 +
45.47 + public String getDisplayName() {
45.48 + return "Waveform";
45.49 + }
45.50 +
45.51 + public Image getIcon() {
45.52 + return ICON;
45.53 + }
45.54 +
45.55 + public HelpCtx getHelpCtx() {
45.56 + return null;
45.57 + }
45.58 +
45.59 + public String preferredID() {
45.60 + return WavTopComponent.PREFERRED_ID;
45.61 + }
45.62 +
45.63 + public MultiViewElement createElement() {
45.64 + return new WavTopComponent(dobj);
45.65 + }
45.66 +
45.67 + public void setWavDataObject(DataObject wav) {
45.68 + dobj = wav;
45.69 + }
45.70 +
45.71 + private void writeObject(ObjectOutputStream out) throws IOException
45.72 + {
45.73 + out.defaultWriteObject();
45.74 + }
45.75 +}
46.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
46.2 +++ b/platform/samples/AudioStation/wavutils/build.xml Thu Nov 02 01:01:27 2006 +0000
46.3 @@ -0,0 +1,8 @@
46.4 +<?xml version="1.0" encoding="UTF-8"?>
46.5 +<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
46.6 +<!-- for some information on what you could do (e.g. targets to override). -->
46.7 +<!-- If you delete this file and reopen the project it will be recreated. -->
46.8 +<project name="org.foo.wavutils" default="netbeans" basedir=".">
46.9 + <description>Builds, tests, and runs the project org.foo.wavutils.</description>
46.10 + <import file="nbproject/build-impl.xml"/>
46.11 +</project>
47.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
47.2 +++ b/platform/samples/AudioStation/wavutils/manifest.mf Thu Nov 02 01:01:27 2006 +0000
47.3 @@ -0,0 +1,6 @@
47.4 +Manifest-Version: 1.0
47.5 +OpenIDE-Module: org.foo.wavutils
47.6 +OpenIDE-Module-Layer: org/foo/wavutils/layer.xml
47.7 +OpenIDE-Module-Localizing-Bundle: org/foo/wavutils/Bundle.properties
47.8 +OpenIDE-Module-Specification-Version: 1.0
47.9 +
48.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
48.2 +++ b/platform/samples/AudioStation/wavutils/nbproject/build-impl.xml Thu Nov 02 01:01:27 2006 +0000
48.3 @@ -0,0 +1,30 @@
48.4 +<?xml version="1.0" encoding="UTF-8"?>
48.5 +<!--
48.6 +*** GENERATED FROM project.xml - DO NOT EDIT ***
48.7 +*** EDIT ../build.xml INSTEAD ***
48.8 +-->
48.9 +<project name="org.foo.wavutils-impl" basedir=".." xmlns:nbmproject="http://www.netbeans.org/ns/nb-module-project/2">
48.10 + <property file="nbproject/private/suite-private.properties"/>
48.11 + <property file="nbproject/suite.properties"/>
48.12 + <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
48.13 + <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
48.14 + <property file="${suite.dir}/nbproject/platform.properties"/>
48.15 + <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
48.16 + <attribute name="name"/>
48.17 + <attribute name="value"/>
48.18 + <sequential>
48.19 + <property name="@{name}" value="${@{value}}"/>
48.20 + </sequential>
48.21 + </macrodef>
48.22 + <property file="${user.properties.file}"/>
48.23 + <nbmproject:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir"/>
48.24 + <nbmproject:property name="netbeans.dest.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir"/>
48.25 + <fail message="You must define 'nbplatform.${nbplatform.active}.harness.dir'">
48.26 + <condition>
48.27 + <not>
48.28 + <available file="${harness.dir}" type="dir"/>
48.29 + </not>
48.30 + </condition>
48.31 + </fail>
48.32 + <import file="${harness.dir}/build.xml"/>
48.33 +</project>
49.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
49.2 +++ b/platform/samples/AudioStation/wavutils/nbproject/genfiles.properties Thu Nov 02 01:01:27 2006 +0000
49.3 @@ -0,0 +1,8 @@
49.4 +build.xml.data.CRC32=3dc40a7c
49.5 +build.xml.script.CRC32=78178f66
49.6 +build.xml.stylesheet.CRC32=77ef55dd
49.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
49.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
49.9 +nbproject/build-impl.xml.data.CRC32=3dc40a7c
49.10 +nbproject/build-impl.xml.script.CRC32=6d47b03e
49.11 +nbproject/build-impl.xml.stylesheet.CRC32=2607fe5f
50.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
50.2 +++ b/platform/samples/AudioStation/wavutils/nbproject/platform.properties Thu Nov 02 01:01:27 2006 +0000
50.3 @@ -0,0 +1,132 @@
50.4 +# Deprecated since 5.0u1; for compatibility with 5.0:
50.5 +disabled.clusters=\
50.6 + enterprise3,\
50.7 + harness,\
50.8 + nb5.5
50.9 +disabled.modules=\
50.10 + javax.jmi.model,\
50.11 + javax.jmi.reflect,\
50.12 + org.apache.tools.ant.module,\
50.13 + org.apache.xml.resolver,\
50.14 + org.netbeans.api.debugger,\
50.15 + org.netbeans.api.debugger.jpda,\
50.16 + org.netbeans.api.java,\
50.17 + org.netbeans.api.mdr,\
50.18 + org.netbeans.api.xml,\
50.19 + org.netbeans.core.ide,\
50.20 + org.netbeans.jmi.javamodel,\
50.21 + org.netbeans.lib.cvsclient,\
50.22 + org.netbeans.libs.commons_logging,\
50.23 + org.netbeans.libs.formlayout,\
50.24 + org.netbeans.libs.jsch,\
50.25 + org.netbeans.libs.xerces,\
50.26 + org.netbeans.modules.ant.browsetask,\
50.27 + org.netbeans.modules.ant.debugger,\
50.28 + org.netbeans.modules.ant.freeform,\
50.29 + org.netbeans.modules.ant.grammar,\
50.30 + org.netbeans.modules.apisupport.ant,\
50.31 + org.netbeans.modules.apisupport.feedreader,\
50.32 + org.netbeans.modules.apisupport.paintapp,\
50.33 + org.netbeans.modules.apisupport.project,\
50.34 + org.netbeans.modules.apisupport.refactoring,\
50.35 + org.netbeans.modules.beans,\
50.36 + org.netbeans.modules.classfile,\
50.37 + org.netbeans.modules.clazz,\
50.38 + org.netbeans.modules.css,\
50.39 + org.netbeans.modules.db,\
50.40 + org.netbeans.modules.db.core,\
50.41 + org.netbeans.modules.db.sql.editor,\
50.42 + org.netbeans.modules.dbapi,\
50.43 + org.netbeans.modules.debugger.jpda,\
50.44 + org.netbeans.modules.debugger.jpda.ant,\
50.45 + org.netbeans.modules.debugger.jpda.ui,\
50.46 + org.netbeans.modules.defaults,\
50.47 + org.netbeans.modules.diff,\
50.48 + org.netbeans.modules.editor,\
50.49 + org.netbeans.modules.editor.bookmarks,\
50.50 + org.netbeans.modules.editor.codetemplates,\
50.51 + org.netbeans.modules.editor.completion,\
50.52 + org.netbeans.modules.editor.errorstripe,\
50.53 + org.netbeans.modules.editor.errorstripe.api,\
50.54 + org.netbeans.modules.editor.hints,\
50.55 + org.netbeans.modules.editor.plain,\
50.56 + org.netbeans.modules.editor.plain.lib,\
50.57 + org.netbeans.modules.editor.settings,\
50.58 + org.netbeans.modules.editor.settings.storage,\
50.59 + org.netbeans.modules.editor.structure,\
50.60 + org.netbeans.modules.extbrowser,\
50.61 + org.netbeans.modules.form,\
50.62 + org.netbeans.modules.html,\
50.63 + org.netbeans.modules.html.editor,\
50.64 + org.netbeans.modules.html.editor.lib,\
50.65 + org.netbeans.modules.httpserver,\
50.66 + org.netbeans.modules.i18n,\
50.67 + org.netbeans.modules.i18n.form,\
50.68 + org.netbeans.modules.image,\
50.69 + org.netbeans.modules.j2ee.metadata,\
50.70 + org.netbeans.modules.j2ee.persistenceapi,\
50.71 + org.netbeans.modules.java,\
50.72 + org.netbeans.modules.java.editor,\
50.73 + org.netbeans.modules.java.editor.lib,\
50.74 + org.netbeans.modules.java.examples,\
50.75 + org.netbeans.modules.java.freeform,\
50.76 + org.netbeans.modules.java.hints,\
50.77 + org.netbeans.modules.java.j2seplatform,\
50.78 + org.netbeans.modules.java.j2seproject,\
50.79 + org.netbeans.modules.java.navigation,\
50.80 + org.netbeans.modules.java.platform,\
50.81 + org.netbeans.modules.java.project,\
50.82 + org.netbeans.modules.javacore,\
50.83 + org.netbeans.modules.javadoc,\
50.84 + org.netbeans.modules.jmiutils,\
50.85 + org.netbeans.modules.junit,\
50.86 + org.netbeans.modules.mdr,\
50.87 + org.netbeans.modules.options.api,\
50.88 + org.netbeans.modules.options.editor,\
50.89 + org.netbeans.modules.project.ant,\
50.90 + org.netbeans.modules.project.libraries,\
50.91 + org.netbeans.modules.projectapi,\
50.92 + org.netbeans.modules.projectui,\
50.93 + org.netbeans.modules.projectuiapi,\
50.94 + org.netbeans.modules.properties,\
50.95 + org.netbeans.modules.properties.syntax,\
50.96 + org.netbeans.modules.refactoring,\
50.97 + org.netbeans.modules.schema2beans,\
50.98 + org.netbeans.modules.servletapi,\
50.99 + org.netbeans.modules.suggestions_framework,\
50.100 + org.netbeans.modules.tasklist.core,\
50.101 + org.netbeans.modules.tasklist.docscan,\
50.102 + org.netbeans.modules.usersguide,\
50.103 + org.netbeans.modules.utilities,\
50.104 + org.netbeans.modules.utilities.project,\
50.105 + org.netbeans.modules.versioning,\
50.106 + org.netbeans.modules.versioning.system.cvss,\
50.107 + org.netbeans.modules.websvc.clientapi,\
50.108 + org.netbeans.modules.websvc.jaxrpc16,\
50.109 + org.netbeans.modules.websvc.jaxws20,\
50.110 + org.netbeans.modules.websvc.jaxwsapi,\
50.111 + org.netbeans.modules.websvc.jaxwsmodel,\
50.112 + org.netbeans.modules.xml.catalog,\
50.113 + org.netbeans.modules.xml.core,\
50.114 + org.netbeans.modules.xml.multiview,\
50.115 + org.netbeans.modules.xml.retriever,\
50.116 + org.netbeans.modules.xml.schema,\
50.117 + org.netbeans.modules.xml.schema.model,\
50.118 + org.netbeans.modules.xml.tax,\
50.119 + org.netbeans.modules.xml.text,\
50.120 + org.netbeans.modules.xml.tools,\
50.121 + org.netbeans.modules.xml.wsdl.model,\
50.122 + org.netbeans.modules.xml.xam,\
50.123 + org.netbeans.modules.xml.xdm,\
50.124 + org.netbeans.modules.xsl,\
50.125 + org.netbeans.spi.debugger.ui,\
50.126 + org.netbeans.spi.navigator,\
50.127 + org.netbeans.spi.palette,\
50.128 + org.netbeans.spi.viewmodel,\
50.129 + org.netbeans.tasklistapi,\
50.130 + org.openide.src,\
50.131 + org.openidex.util
50.132 +enabled.clusters=\
50.133 + ide7,\
50.134 + platform6
50.135 +nbplatform.active=default
51.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
51.2 +++ b/platform/samples/AudioStation/wavutils/nbproject/project.properties Thu Nov 02 01:01:27 2006 +0000
51.3 @@ -0,0 +1,1 @@
51.4 +javac.source=1.5
52.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
52.2 +++ b/platform/samples/AudioStation/wavutils/nbproject/project.xml Thu Nov 02 01:01:27 2006 +0000
52.3 @@ -0,0 +1,23 @@
52.4 +<?xml version="1.0" encoding="UTF-8"?>
52.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
52.6 + <type>org.netbeans.modules.apisupport.project</type>
52.7 + <configuration>
52.8 + <data xmlns="http://www.netbeans.org/ns/nb-module-project/2">
52.9 + <code-name-base>org.foo.wavutils</code-name-base>
52.10 + <suite-component/>
52.11 + <module-dependencies>
52.12 + <dependency>
52.13 + <code-name-base>org.openide.util</code-name-base>
52.14 + <build-prerequisite/>
52.15 + <compile-dependency/>
52.16 + <run-dependency>
52.17 + <specification-version>6.8.22</specification-version>
52.18 + </run-dependency>
52.19 + </dependency>
52.20 + </module-dependencies>
52.21 + <public-packages>
52.22 + <package>org.foo.wavutils</package>
52.23 + </public-packages>
52.24 + </data>
52.25 + </configuration>
52.26 +</project>
53.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
53.2 +++ b/platform/samples/AudioStation/wavutils/nbproject/suite.properties Thu Nov 02 01:01:27 2006 +0000
53.3 @@ -0,0 +1,1 @@
53.4 +suite.dir=${basedir}/..
54.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
54.2 +++ b/platform/samples/AudioStation/wavutils/src/org/foo/wavutils/AudioUI.java Thu Nov 02 01:01:27 2006 +0000
54.3 @@ -0,0 +1,96 @@
54.4 +/*
54.5 + * The contents of this file are subject to the terms of the Common Development
54.6 + * and Distribution License (the License). You may not use this file except in
54.7 + * compliance with the License.
54.8 + *
54.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
54.10 + * or http://www.netbeans.org/cddl.txt.
54.11 + *
54.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
54.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
54.14 + * If applicable, add the following below the CDDL Header, with the fields
54.15 + * enclosed by brackets [] replaced by your own identifying information:
54.16 + * "Portions Copyrighted [year] [name of copyright owner]"
54.17 + */
54.18 +
54.19 +package org.foo.wavutils;
54.20 +
54.21 +import org.openide.util.TaskListener;
54.22 +
54.23 +/**
54.24 + * An interface for the audio GUI to implement, for interfacing with
54.25 + * the javasound code.
54.26 + *
54.27 + * @author runger
54.28 + */
54.29 +public interface AudioUI extends TaskListener {
54.30 +
54.31 + SamplingGraph getSamplingGraph();
54.32 +
54.33 + WrappedAudioInputStream getAudioInputStream();
54.34 +
54.35 + void setAudioInputStream(WrappedAudioInputStream stream);
54.36 +
54.37 + /**
54.38 + * Represents a selected portion of the audio stream.
54.39 + * Offset and length are indices into the audio data.
54.40 + */
54.41 + public static class Selection
54.42 + {
54.43 + public Selection( int offset, int length )
54.44 + {
54.45 + this.offset = offset;
54.46 + this.length = length;
54.47 + }
54.48 +
54.49 + /**
54.50 + * Gets the offset and length of the audio selected by the user
54.51 + * in the sampling graph.
54.52 + */
54.53 + public static Selection getSelection(AudioUI audioUI)
54.54 + {
54.55 + SamplingGraph samplingGraph = audioUI.getSamplingGraph();
54.56 + synchronized( samplingGraph )
54.57 + {
54.58 + double dStart = samplingGraph.getSelectionStart();
54.59 + double dEnd = samplingGraph.getSelectionEnd();
54.60 +
54.61 + // do we have a non-zero selection?
54.62 + if( Math.abs( dStart - dEnd ) == 0 )
54.63 + {
54.64 + return null;
54.65 + }
54.66 + else
54.67 + {
54.68 + // make sure they're in the right order
54.69 + if( dEnd < dStart )
54.70 + {
54.71 + double d = dEnd;
54.72 + dEnd = dStart;
54.73 + dStart = d;
54.74 + }
54.75 +
54.76 + double dWidth = samplingGraph.getWidth();
54.77 +
54.78 + WrappedAudioInputStream pcmStream = audioUI.getAudioInputStream();
54.79 +
54.80 + if( pcmStream == null )
54.81 + {
54.82 + return null;
54.83 + }
54.84 + double dPromptLength = pcmStream.getLength();
54.85 +
54.86 + int iBeginIndex = (int)( (dStart / dWidth) * dPromptLength );
54.87 + int iEndIndex = (int)( (dEnd / dWidth) * dPromptLength );
54.88 + int iLength = iEndIndex - iBeginIndex;
54.89 +
54.90 + return new Selection( iBeginIndex, iLength );
54.91 + }
54.92 + }
54.93 + }
54.94 +
54.95 + public int offset;
54.96 + public int length;
54.97 + }
54.98 +
54.99 +}
55.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
55.2 +++ b/platform/samples/AudioStation/wavutils/src/org/foo/wavutils/Bundle.properties Thu Nov 02 01:01:27 2006 +0000
55.3 @@ -0,0 +1,2 @@
55.4 +OpenIDE-Module-Name=wavutils
55.5 +OpenIDE-Module-Short-Description=Utilities for handling WAV files
56.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
56.2 +++ b/platform/samples/AudioStation/wavutils/src/org/foo/wavutils/FFTGraph.java Thu Nov 02 01:01:27 2006 +0000
56.3 @@ -0,0 +1,251 @@
56.4 +/*
56.5 + * The contents of this file are subject to the terms of the Common Development
56.6 + * and Distribution License (the License). You may not use this file except in
56.7 + * compliance with the License.
56.8 + *
56.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
56.10 + * or http://www.netbeans.org/cddl.txt.
56.11 + *
56.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
56.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
56.14 + * If applicable, add the following below the CDDL Header, with the fields
56.15 + * enclosed by brackets [] replaced by your own identifying information:
56.16 + * "Portions Copyrighted [year] [name of copyright owner]"
56.17 + */
56.18 +
56.19 +package org.foo.wavutils;
56.20 +
56.21 +import java.awt.Color;
56.22 +import java.awt.Dimension;
56.23 +import java.awt.Font;
56.24 +import java.awt.Graphics;
56.25 +import java.awt.Graphics2D;
56.26 +import java.awt.font.FontRenderContext;
56.27 +import java.awt.font.LineBreakMeasurer;
56.28 +import java.awt.font.TextAttribute;
56.29 +import java.awt.font.TextLayout;
56.30 +import java.awt.geom.Line2D;
56.31 +import java.io.IOException;
56.32 +import java.text.AttributedCharacterIterator;
56.33 +import java.text.AttributedString;
56.34 +import java.util.ArrayList;
56.35 +import java.util.List;
56.36 +import javax.sound.sampled.AudioFormat;
56.37 +import javax.swing.JPanel;
56.38 +import org.openide.ErrorManager;
56.39 +
56.40 +/**
56.41 + *
56.42 + * @author runger
56.43 + */
56.44 +public class FFTGraph extends JPanel {
56.45 +
56.46 + //////////////////// CONSTRUCTORS /////////////////////////
56.47 +
56.48 + public FFTGraph() {
56.49 + setBackground(Color.black);
56.50 + }
56.51 +
56.52 + //////////////////// METHODS //////////////////////////////
56.53 +
56.54 + public void clearGraph()
56.55 + {
56.56 + freqData = null;
56.57 + maxFreq = 0f;
56.58 + m_sError = null;
56.59 + repaint();
56.60 + }
56.61 +
56.62 + public void createGraph( WrappedAudioInputStream audioInputStream )
56.63 + {
56.64 + if( audioInputStream != null && audioInputStream.getLength() > 0)
56.65 + {
56.66 + format = audioInputStream.getFormat();
56.67 + byte[] audioBytes = null;
56.68 + try
56.69 + {
56.70 + audioBytes = new byte[audioInputStream.getLength()];
56.71 + audioInputStream.read(audioBytes);
56.72 + }
56.73 + catch( Exception ex )
56.74 + {
56.75 + ErrorManager.getDefault().notify(ex);
56.76 + return;
56.77 + }
56.78 +
56.79 + createGraph(audioBytes);
56.80 +
56.81 + try
56.82 + {
56.83 + audioInputStream.reset();
56.84 + }
56.85 + catch( IOException ex )
56.86 + {
56.87 + ErrorManager.getDefault().notify(ex);
56.88 + }
56.89 + }
56.90 + repaint();
56.91 + }
56.92 +
56.93 + private void createGraph(byte[] audioBytes)
56.94 + {
56.95 + freqData = null; // clear the old FFT data
56.96 + maxFreq = 0f;
56.97 + float[] samples;
56.98 +
56.99 + if (format.getSampleSizeInBits() == 16)
56.100 + {
56.101 + int iLengthInSamples = audioBytes.length / 2;
56.102 + int bits = (int)Math.ceil(Math.log(iLengthInSamples) / Math.log(2));
56.103 + samples = new float[(int)Math.pow(2, bits)];
56.104 +
56.105 + if (format.isBigEndian())
56.106 + {
56.107 + for (int i = 0; i < iLengthInSamples; i++)
56.108 + {
56.109 + /* First byte is MSB (high order) */
56.110 + int MSB = audioBytes[2*i];
56.111 + /* Second byte is LSB (low order) */
56.112 + int LSB = audioBytes[2*i+1];
56.113 + samples[i] = MSB << 8 | (255 & LSB);
56.114 + }
56.115 + }
56.116 + else
56.117 + {
56.118 + for (int i = 0; i < iLengthInSamples; i++)
56.119 + {
56.120 + /* First byte is LSB (low order) */
56.121 + int LSB = audioBytes[2*i];
56.122 + /* Second byte is MSB (high order) */
56.123 + int MSB = audioBytes[2*i+1];
56.124 + samples[i] = MSB << 8 | (255 & LSB);
56.125 + }
56.126 + }
56.127 + }
56.128 + else if (format.getSampleSizeInBits() == 8)
56.129 + {
56.130 + int iLengthInSamples = audioBytes.length;
56.131 + int bits = (int)Math.ceil(Math.log(iLengthInSamples) / Math.log(2));
56.132 + samples = new float[(int)Math.pow(2, bits)];
56.133 +
56.134 + if (format.getEncoding().toString().startsWith("PCM_SIGN"))
56.135 + {
56.136 + for (int i = 0; i < audioBytes.length; i++)
56.137 + {
56.138 + samples[i] = audioBytes[i];
56.139 + }
56.140 + }
56.141 + else
56.142 + {
56.143 + for (int i = 0; i < audioBytes.length; i++)
56.144 + {
56.145 + samples[i] = audioBytes[i] - 128;
56.146 + }
56.147 + }
56.148 + }
56.149 + else
56.150 + {
56.151 + samples = null;
56.152 + assert false : "Sample size is not 8 or 16!";
56.153 + }
56.154 +
56.155 + // perform FFT on the samples
56.156 +
56.157 + // an "empty" wav file has 1 sample
56.158 + if (samples.length < 2)
56.159 + freqData = new float[] { 0 };
56.160 + else
56.161 + freqData = new FastFourierTransform().fftMag(samples);
56.162 +
56.163 + for (float freq : freqData)
56.164 + {
56.165 + maxFreq = Math.max(maxFreq, freq);
56.166 + }
56.167 + }
56.168 +
56.169 + public String getErrorString()
56.170 + {
56.171 + return m_sError;
56.172 + }
56.173 +
56.174 + public void paint(Graphics g)
56.175 + {
56.176 + int INFOPAD = 15;
56.177 + Dimension d = getSize();
56.178 + int w = d.width;
56.179 + int h = d.height - INFOPAD;
56.180 +
56.181 + List<Line2D> lines = new ArrayList<Line2D>();
56.182 + if (freqData != null)
56.183 + {
56.184 + for (int i=0; i < freqData.length; i++)
56.185 + {
56.186 + float freq = freqData[i];
56.187 + float x = (float)w * i / freqData.length;
56.188 + float y = (freq * h / maxFreq);
56.189 + lines.add(new Line2D.Float(x, h, x, h-y));
56.190 + }
56.191 + }
56.192 +
56.193 + Graphics2D g2 = (Graphics2D) g;
56.194 + g2.setBackground(getBackground());
56.195 + g2.clearRect(0, 0, w, h);
56.196 + g2.setColor(Color.white);
56.197 + g2.fillRect(0, h, w, INFOPAD);
56.198 +
56.199 + if (m_sError != null)
56.200 + {
56.201 + // Write out an error string instead of the wave form
56.202 +
56.203 + g2.setColor(s_jfcBlue);
56.204 + g2.setFont(new Font("serif", Font.BOLD, 18));
56.205 + g2.drawString("ERROR", 5, 20);
56.206 + AttributedString as = new AttributedString(m_sError);
56.207 + as.addAttribute(TextAttribute.FONT, s_font12, 0, m_sError.length());
56.208 + AttributedCharacterIterator aci = as.getIterator();
56.209 + FontRenderContext frc = g2.getFontRenderContext();
56.210 + LineBreakMeasurer lbm = new LineBreakMeasurer(aci, frc);
56.211 + float x = 5, y = 25;
56.212 + lbm.setPosition(0);
56.213 + while (lbm.getPosition() < m_sError.length()) {
56.214 + TextLayout tl = lbm.nextLayout(w-x-5);
56.215 + if (!tl.isLeftToRight()) {
56.216 + x = w - tl.getAdvance();
56.217 + }
56.218 + tl.draw(g2, x, y += tl.getAscent());
56.219 + y += tl.getDescent() + tl.getLeading();
56.220 + }
56.221 + }
56.222 + else
56.223 + {
56.224 + // write the length and position at the bottom
56.225 +
56.226 + g2.setColor(Color.black);
56.227 + g2.setFont(s_font12);
56.228 + g2.drawString("Fast Fourier Transform", 3, h + INFOPAD -4);
56.229 +
56.230 + if (!lines.isEmpty()) {
56.231 + // .. render sampling graph ..
56.232 + g2.setColor(s_jfcBlue);
56.233 + for (int i = 1; i < lines.size(); i++) {
56.234 + g2.draw((Line2D) lines.get(i));
56.235 + }
56.236 + }
56.237 +
56.238 + }
56.239 + }
56.240 +
56.241 + //////////////////// INSTANCE VARIABLES ////////////////////
56.242 +
56.243 + private String m_sError;
56.244 + private float[] freqData;
56.245 + private float maxFreq;
56.246 + private AudioFormat format;
56.247 + private double m_dDuration;
56.248 +
56.249 + //////////////////// CONSTANTS //////////////////////////////
56.250 + private static final Font s_font12 = new Font("serif", Font.PLAIN, 12);
56.251 + private static final Color s_jfcBlue = new Color(204, 204, 255);
56.252 + private static final Color s_pink = new Color(255, 175, 175);
56.253 +
56.254 +}
57.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
57.2 +++ b/platform/samples/AudioStation/wavutils/src/org/foo/wavutils/FastFourierTransform.java Thu Nov 02 01:01:27 2006 +0000
57.3 @@ -0,0 +1,82 @@
57.4 +/*
57.5 + * Public domain file by Tsan-Kuang Lee
57.6 + * Found at: http://www.ling.upenn.edu/~tklee/Projects/dsp/
57.7 + */
57.8 +
57.9 +package org.foo.wavutils;
57.10 +
57.11 +public final class FastFourierTransform {
57.12 +
57.13 + private int n, nu;
57.14 +
57.15 + private int bitrev(int j) {
57.16 +
57.17 + int j2;
57.18 + int j1 = j;
57.19 + int k = 0;
57.20 + for (int i = 1; i <= nu; i++) {
57.21 + j2 = j1/2;
57.22 + k = 2*k + j1 - 2*j2;
57.23 + j1 = j2;
57.24 + }
57.25 + return k;
57.26 + }
57.27 +
57.28 + public final float[] fftMag(float[] x) {
57.29 + // assume n is a power of 2
57.30 + n = x.length;
57.31 + nu = (int)(Math.log(n)/Math.log(2));
57.32 + int n2 = n/2;
57.33 + int nu1 = nu - 1;
57.34 + float[] xre = new float[n];
57.35 + float[] xim = new float[n];
57.36 + float[] mag = new float[n2];
57.37 + float tr, ti, p, arg, c, s;
57.38 + for (int i = 0; i < n; i++) {
57.39 + xre[i] = x[i];
57.40 + xim[i] = 0.0f;
57.41 + }
57.42 + int k = 0;
57.43 +
57.44 + for (int l = 1; l <= nu; l++) {
57.45 + while (k < n) {
57.46 + for (int i = 1; i <= n2; i++) {
57.47 + p = bitrev (k >> nu1);
57.48 + arg = 2 * (float) Math.PI * p / n;
57.49 + c = (float) Math.cos (arg);
57.50 + s = (float) Math.sin (arg);
57.51 + tr = xre[k+n2]*c + xim[k+n2]*s;
57.52 + ti = xim[k+n2]*c - xre[k+n2]*s;
57.53 + xre[k+n2] = xre[k] - tr;
57.54 + xim[k+n2] = xim[k] - ti;
57.55 + xre[k] += tr;
57.56 + xim[k] += ti;
57.57 + k++;
57.58 + }
57.59 + k += n2;
57.60 + }
57.61 + k = 0;
57.62 + nu1--;
57.63 + n2 = n2/2;
57.64 + }
57.65 + k = 0;
57.66 + int r;
57.67 + while (k < n) {
57.68 + r = bitrev (k);
57.69 + if (r > k) {
57.70 + tr = xre[k];
57.71 + ti = xim[k];
57.72 + xre[k] = xre[r];
57.73 + xim[k] = xim[r];
57.74 + xre[r] = tr;
57.75 + xim[r] = ti;
57.76 + }
57.77 + k++;
57.78 + }
57.79 +
57.80 + mag[0] = (float) (Math.sqrt(xre[0]*xre[0] + xim[0]*xim[0]))/n;
57.81 + for (int i = 1; i < n/2; i++)
57.82 + mag[i]= 2 * (float) (Math.sqrt(xre[i]*xre[i] + xim[i]*xim[i]))/n;
57.83 + return mag;
57.84 + }
57.85 +}
58.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
58.2 +++ b/platform/samples/AudioStation/wavutils/src/org/foo/wavutils/Formats.java Thu Nov 02 01:01:27 2006 +0000
58.3 @@ -0,0 +1,63 @@
58.4 +/*
58.5 + * The contents of this file are subject to the terms of the Common Development
58.6 + * and Distribution License (the License). You may not use this file except in
58.7 + * compliance with the License.
58.8 + *
58.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
58.10 + * or http://www.netbeans.org/cddl.txt.
58.11 + *
58.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
58.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
58.14 + * If applicable, add the following below the CDDL Header, with the fields
58.15 + * enclosed by brackets [] replaced by your own identifying information:
58.16 + * "Portions Copyrighted [year] [name of copyright owner]"
58.17 + */
58.18 +package org.foo.wavutils;
58.19 +
58.20 +import javax.sound.sampled.AudioFormat;
58.21 +
58.22 +public class Formats {
58.23 + /** Never instantiated */
58.24 + private Formats() {
58.25 + }
58.26 +
58.27 + /**
58.28 + * All WAV files, when opened, are converted to this format
58.29 + * for working in-memory.
58.30 + */
58.31 + public static final AudioFormat INTERNAL_FORMAT =
58.32 + new AudioFormat( AudioFormat.Encoding.PCM_SIGNED,
58.33 + 8000f, //sample rate
58.34 + 16, // bits per sample
58.35 + 1, // channels
58.36 + 2, // frame rate
58.37 + 8000f, // framesize
58.38 + true); // isBigEndian
58.39 +
58.40 + public static final AudioFormat PCM_UNSIGNED_FORMAT =
58.41 + new AudioFormat( AudioFormat.Encoding.PCM_UNSIGNED,
58.42 + 8000f, //sample rate
58.43 + 16, // bits per sample
58.44 + 1, // channels
58.45 + 2, // frame rate
58.46 + 8000f, // framesize
58.47 + true); // isBigEndian
58.48 +
58.49 + public static final AudioFormat ULAW_FORMAT =
58.50 + new AudioFormat( AudioFormat.Encoding.ULAW,
58.51 + 8000f, //sample rate
58.52 + 8, // bits per sample
58.53 + 1, // channels
58.54 + 1, // frame rate
58.55 + 8000f, // framesize
58.56 + true); // isBigEndian
58.57 +
58.58 + public static final AudioFormat ALAW_FORMAT =
58.59 + new AudioFormat( AudioFormat.Encoding.ALAW,
58.60 + 8000f, //sample rate
58.61 + 8, // bits per sample
58.62 + 1, // channels
58.63 + 1, // frame rate
58.64 + 8000f, // framesize
58.65 + true); // isBigEndian
58.66 +}
59.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
59.2 +++ b/platform/samples/AudioStation/wavutils/src/org/foo/wavutils/Player.java Thu Nov 02 01:01:27 2006 +0000
59.3 @@ -0,0 +1,205 @@
59.4 +/*
59.5 + * The contents of this file are subject to the terms of the Common Development
59.6 + * and Distribution License (the License). You may not use this file except in
59.7 + * compliance with the License.
59.8 + *
59.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
59.10 + * or http://www.netbeans.org/cddl.txt.
59.11 + *
59.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
59.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
59.14 + * If applicable, add the following below the CDDL Header, with the fields
59.15 + * enclosed by brackets [] replaced by your own identifying information:
59.16 + * "Portions Copyrighted [year] [name of copyright owner]"
59.17 + */
59.18 +package org.foo.wavutils;
59.19 +
59.20 +
59.21 +import java.io.IOException;
59.22 +
59.23 +import javax.sound.sampled.AudioFormat;
59.24 +import javax.sound.sampled.AudioSystem;
59.25 +import javax.sound.sampled.DataLine;
59.26 +import javax.sound.sampled.LineUnavailableException;
59.27 +import javax.sound.sampled.SourceDataLine;
59.28 +
59.29 +import org.openide.ErrorManager;
59.30 +import org.openide.util.NbBundle;
59.31 +import org.openide.util.RequestProcessor;
59.32 +
59.33 +/**
59.34 + * Writes the audio data from an AudioUI to a JavaSound outpout line.
59.35 + *
59.36 + * @author Rich Unger
59.37 + */
59.38 +public class Player implements Runnable {
59.39 +
59.40 + public Player( AudioUI editor )
59.41 + {
59.42 + audioUI = editor;
59.43 + }
59.44 +
59.45 + public void start() {
59.46 + task = RequestProcessor.getDefault().post(this);
59.47 + task.addTaskListener(audioUI);
59.48 + }
59.49 +
59.50 + public void pause()
59.51 + {
59.52 + if( task != null )
59.53 + {
59.54 + if( dataLine.isActive() )
59.55 + {
59.56 + dataLine.stop();
59.57 + }
59.58 + else
59.59 + {
59.60 + dataLine.start();
59.61 + }
59.62 + }
59.63 + }
59.64 +
59.65 + public void stop() {
59.66 + task = null;
59.67 + }
59.68 +
59.69 + private void shutDown()
59.70 + {
59.71 + SamplingGraph graph = audioUI.getSamplingGraph();
59.72 +
59.73 + graph.setPlaybackLine(null);
59.74 +
59.75 + if (task != null) {
59.76 + task = null;
59.77 + graph.stop();
59.78 + }
59.79 + }
59.80 +
59.81 + public void run() {
59.82 + WrappedAudioInputStream pcmStream = audioUI.getAudioInputStream();
59.83 +
59.84 + // make sure we have something to play
59.85 + if (pcmStream == null) {
59.86 + ErrorManager.getDefault().log(ErrorManager.ERROR,
59.87 + NbBundle.getMessage(Player.class, "NoAudioDataToLoad"));
59.88 + shutDown();
59.89 + return;
59.90 + }
59.91 +
59.92 + // if there's a selection, we'll just play that part.
59.93 + AudioUI.Selection curSelection = AudioUI.Selection.getSelection(audioUI);
59.94 +
59.95 + AudioFormat pcmFormat = pcmStream.getFormat();
59.96 +
59.97 + // define the required attributes for our line,
59.98 + // and make sure a compatible line is supported.
59.99 +
59.100 + DataLine.Info info = new DataLine.Info(SourceDataLine.class,
59.101 + pcmFormat);
59.102 + if (!AudioSystem.isLineSupported(info)) {
59.103 + ErrorManager.getDefault().log(ErrorManager.ERROR,
59.104 + "Line matching " + info + " not supported.");
59.105 + shutDown();
59.106 + return;
59.107 + }
59.108 +
59.109 + // get and open the source data line for playback.
59.110 +
59.111 + try {
59.112 + dataLine = (SourceDataLine) AudioSystem.getLine(info);
59.113 + dataLine.open(pcmFormat, BUFSIZE);
59.114 + } catch (LineUnavailableException ex) {
59.115 + ErrorManager em = ErrorManager.getDefault();
59.116 + em.notify(em.annotate(ex, "Unable to open the line: " + ex.getMessage()));
59.117 + shutDown();
59.118 + return;
59.119 + }
59.120 +
59.121 + // play back the captured audio data
59.122 +
59.123 + int frameSizeInBytes = pcmFormat.getFrameSize();
59.124 + int bufferLengthInFrames = dataLine.getBufferSize() / 8;
59.125 + int bufferLengthInBytes = bufferLengthInFrames * frameSizeInBytes;
59.126 + byte[] data = new byte[bufferLengthInBytes];
59.127 + int numBytesRead = 0;
59.128 +
59.129 + // if there's a selection, just read that
59.130 + int iTotalBytesRemaining;
59.131 + if( curSelection == null )
59.132 + {
59.133 + iTotalBytesRemaining = pcmStream.getLength();
59.134 + }
59.135 + else
59.136 + {
59.137 + try
59.138 + {
59.139 + pcmStream.skip( curSelection.offset );
59.140 + }
59.141 + catch( IOException ex )
59.142 + {
59.143 + ErrorManager em = ErrorManager.getDefault();
59.144 + em.notify(em.annotate(ex,
59.145 + NbBundle.getMessage(Player.class, "PlaybackError") + ex.getMessage()));
59.146 + shutDown();
59.147 + }
59.148 + iTotalBytesRemaining = curSelection.length;
59.149 + }
59.150 +
59.151 + // link the line to the sampling graph
59.152 + audioUI.getSamplingGraph().setPlaybackLine(dataLine);
59.153 +
59.154 + // start the source data line
59.155 + dataLine.start();
59.156 +
59.157 + while (task != null) {
59.158 + try {
59.159 + if ((numBytesRead = pcmStream.read( data, 0,
59.160 + Math.min(iTotalBytesRemaining, data.length) ) ) <= 0) {
59.161 + break;
59.162 + }
59.163 + int numBytesRemaining = numBytesRead;
59.164 + while (numBytesRemaining > 0 ) {
59.165 + numBytesRemaining -= dataLine.write(data, 0, numBytesRemaining);
59.166 + }
59.167 + iTotalBytesRemaining -= numBytesRead;
59.168 + } catch (Exception ex) {
59.169 + ErrorManager em = ErrorManager.getDefault();
59.170 + em.notify(em.annotate(ex,
59.171 + NbBundle.getMessage(Player.class, "PlaybackError") + ex.getMessage()));
59.172 + shutDown();
59.173 + break;
59.174 + }
59.175 + }
59.176 + // we reached the end of the stream. reset the stream,
59.177 + // let the data play out, then stop and close the line.
59.178 + String sShutDownString = null;
59.179 + try
59.180 + {
59.181 + pcmStream.reset();
59.182 + }
59.183 + catch( IOException ex )
59.184 + {
59.185 + ErrorManager em = ErrorManager.getDefault();
59.186 + sShutDownString = NbBundle.getMessage(
59.187 + Player.class, "AudioStreamResetError") + ex.getMessage();
59.188 + em.notify(em.annotate(ex, sShutDownString));
59.189 + }
59.190 +
59.191 + if (task != null) {
59.192 + dataLine.drain();
59.193 + }
59.194 + dataLine.stop();
59.195 + dataLine.close();
59.196 + dataLine = null;
59.197 + shutDown();
59.198 + }
59.199 +
59.200 + /** The line to which audio data is played */
59.201 + private SourceDataLine dataLine;
59.202 +
59.203 + private RequestProcessor.Task task;
59.204 +
59.205 + private final AudioUI audioUI;
59.206 +
59.207 + private static final int BUFSIZE = 16000;
59.208 +}
60.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
60.2 +++ b/platform/samples/AudioStation/wavutils/src/org/foo/wavutils/Recorder.java Thu Nov 02 01:01:27 2006 +0000
60.3 @@ -0,0 +1,148 @@
60.4 +/*
60.5 + * The contents of this file are subject to the terms of the Common Development
60.6 + * and Distribution License (the License). You may not use this file except in
60.7 + * compliance with the License.
60.8 + *
60.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
60.10 + * or http://www.netbeans.org/cddl.txt.
60.11 + *
60.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
60.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
60.14 + * If applicable, add the following below the CDDL Header, with the fields
60.15 + * enclosed by brackets [] replaced by your own identifying information:
60.16 + * "Portions Copyrighted [year] [name of copyright owner]"
60.17 + */
60.18 +package org.foo.wavutils;
60.19 +
60.20 +
60.21 +import java.io.ByteArrayInputStream;
60.22 +import java.io.ByteArrayOutputStream;
60.23 +import java.io.IOException;
60.24 +
60.25 +import javax.sound.sampled.AudioInputStream;
60.26 +import javax.sound.sampled.AudioSystem;
60.27 +import javax.sound.sampled.DataLine;
60.28 +import javax.sound.sampled.LineUnavailableException;
60.29 +import javax.sound.sampled.TargetDataLine;
60.30 +
60.31 +import org.openide.ErrorManager;
60.32 +import org.openide.util.RequestProcessor;
60.33 +
60.34 +/**
60.35 + * Reads the audio data from a JavaSound input line to the PromptEditor.
60.36 + *
60.37 + * @author Rich Unger
60.38 + */
60.39 +public class Recorder implements Runnable {
60.40 +
60.41 + public Recorder( AudioUI editor )
60.42 + {
60.43 + audioUI = editor;
60.44 + }
60.45 +
60.46 + public void start() {
60.47 + task = RequestProcessor.getDefault().post(this);
60.48 + task.addTaskListener(audioUI);
60.49 + }
60.50 +
60.51 + public void stop() {
60.52 + task = null;
60.53 + }
60.54 +
60.55 + private void shutDown()
60.56 + {
60.57 + SamplingGraph graph = audioUI.getSamplingGraph();
60.58 + graph.setCaptureLine(null);
60.59 +
60.60 + if (task != null) {
60.61 + task = null;
60.62 + graph.stop();
60.63 + }
60.64 + }
60.65 +
60.66 + public void run() {
60.67 + // define the required attributes for our line,
60.68 + // and make sure a compatible line is supported.
60.69 +
60.70 + DataLine.Info info = new DataLine.Info(TargetDataLine.class,
60.71 + Formats.INTERNAL_FORMAT);
60.72 +
60.73 + if (!AudioSystem.isLineSupported(info)) {
60.74 + ErrorManager.getDefault().log(ErrorManager.ERROR,
60.75 + "Line matching " + info + " not supported.");
60.76 + shutDown();
60.77 + return;
60.78 + }
60.79 +
60.80 + // get and open the target data line for capture.
60.81 +
60.82 + try {
60.83 + dataLine = (TargetDataLine) AudioSystem.getLine(info);
60.84 + dataLine.open(Formats.INTERNAL_FORMAT, dataLine.getBufferSize());
60.85 + } catch (LineUnavailableException ex) {
60.86 + ErrorManager em = ErrorManager.getDefault();
60.87 + em.notify(em.annotate(ex, "Unable to open the line: " + ex.getMessage()));
60.88 + shutDown();
60.89 + return;
60.90 + } catch (SecurityException ex) {
60.91 + ErrorManager.getDefault().notify(ex);
60.92 + shutDown();
60.93 + return;
60.94 + } catch (Exception ex) {
60.95 + ErrorManager.getDefault().notify(ex);
60.96 + shutDown();
60.97 + return;
60.98 + }
60.99 +
60.100 + // record the audio data
60.101 + ByteArrayOutputStream out = new ByteArrayOutputStream();
60.102 + int frameSizeInBytes = Formats.INTERNAL_FORMAT.getFrameSize();
60.103 + int bufferLengthInFrames = dataLine.getBufferSize() / 8;
60.104 + int bufferLengthInBytes = bufferLengthInFrames * frameSizeInBytes;
60.105 + byte[] data = new byte[bufferLengthInBytes];
60.106 + int numBytesRead;
60.107 +
60.108 + // link the line to the sampling graph
60.109 + audioUI.getSamplingGraph().setCaptureLine(dataLine);
60.110 +
60.111 + // start recording
60.112 + dataLine.start();
60.113 +
60.114 + while (task != null) {
60.115 + if((numBytesRead = dataLine.read(data, 0, bufferLengthInBytes)) == -1) {
60.116 + break;
60.117 + }
60.118 + out.write(data, 0, numBytesRead);
60.119 + }
60.120 +
60.121 + // we reached the end of the stream. stop and close the line.
60.122 + dataLine.stop();
60.123 + dataLine.close();
60.124 + dataLine = null;
60.125 +
60.126 + // stop and close the output stream
60.127 + try {
60.128 + out.flush();
60.129 + out.close();
60.130 + } catch (IOException ex) {
60.131 + ex.printStackTrace();
60.132 + }
60.133 +
60.134 + // load bytes into the audio input stream for playback
60.135 +
60.136 + byte audioBytes[] = out.toByteArray();
60.137 + ByteArrayInputStream bais = new ByteArrayInputStream(audioBytes);
60.138 + AudioInputStream pcmStream = new AudioInputStream(bais,
60.139 + Formats.INTERNAL_FORMAT,
60.140 + audioBytes.length / frameSizeInBytes);
60.141 +
60.142 + WrappedAudioInputStream wrappedStream =
60.143 + new WrappedAudioInputStream( pcmStream );
60.144 +
60.145 + audioUI.setAudioInputStream( wrappedStream );
60.146 + }
60.147 +
60.148 + private TargetDataLine dataLine;
60.149 + private RequestProcessor.Task task;
60.150 + private final AudioUI audioUI;
60.151 +}
61.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
61.2 +++ b/platform/samples/AudioStation/wavutils/src/org/foo/wavutils/SamplingGraph.java Thu Nov 02 01:01:27 2006 +0000
61.3 @@ -0,0 +1,417 @@
61.4 +/*
61.5 + * The contents of this file are subject to the terms of the Common Development
61.6 + * and Distribution License (the License). You may not use this file except in
61.7 + * compliance with the License.
61.8 + *
61.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
61.10 + * or http://www.netbeans.org/cddl.txt.
61.11 + *
61.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
61.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
61.14 + * If applicable, add the following below the CDDL Header, with the fields
61.15 + * enclosed by brackets [] replaced by your own identifying information:
61.16 + * "Portions Copyrighted [year] [name of copyright owner]"
61.17 + */
61.18 +package org.foo.wavutils;
61.19 +
61.20 +
61.21 +import java.awt.BasicStroke;
61.22 +import java.awt.Color;
61.23 +import java.awt.Dimension;
61.24 +import java.awt.Font;
61.25 +import java.awt.Graphics;
61.26 +import java.awt.Graphics2D;
61.27 +import java.awt.event.MouseEvent;
61.28 +import java.awt.font.FontRenderContext;
61.29 +import java.awt.font.LineBreakMeasurer;
61.30 +import java.awt.font.TextAttribute;
61.31 +import java.awt.font.TextLayout;
61.32 +import java.awt.geom.Line2D;
61.33 +import java.io.IOException;
61.34 +import java.text.AttributedCharacterIterator;
61.35 +import java.text.AttributedString;
61.36 +import java.util.ArrayList;
61.37 +import java.util.List;
61.38 +import javax.sound.sampled.AudioFormat;
61.39 +import javax.sound.sampled.DataLine;
61.40 +import javax.swing.JPanel;
61.41 +
61.42 +import org.openide.ErrorManager;
61.43 +
61.44 +/**
61.45 + * Render a WaveForm.
61.46 + *
61.47 + * This is a modified version of the sample code shipped with JavaSound,
61.48 + * written by Brian Lichtenwalter, and licensed royalty-free by Sun Microsystems.
61.49 + *
61.50 + * @author Rich Unger
61.51 + */
61.52 +
61.53 +public class SamplingGraph extends JPanel implements Runnable
61.54 +{
61.55 + //////////////////// CONSTRUCTORS /////////////////////////
61.56 +
61.57 + public SamplingGraph() {
61.58 + setBackground(Color.black);
61.59 +
61.60 + // mouse listeners for handling user selection
61.61 + SamplingGraph.MouseHandler mouseEventHandler =
61.62 + new SamplingGraph.MouseHandler();
61.63 + addMouseMotionListener(mouseEventHandler);
61.64 + addMouseListener(mouseEventHandler);
61.65 +
61.66 + // set the current selection to nothing
61.67 + m_iSelectionStart = m_iSelectionEnd = -1;
61.68 + }
61.69 +
61.70 + //////////////////// METHODS //////////////////////////////
61.71 +
61.72 + public void clearWaveForm()
61.73 + {
61.74 + audioData = null;
61.75 + m_sError = null;
61.76 + clearSelection();
61.77 + repaint();
61.78 + }
61.79 +
61.80 + public void createWaveForm( WrappedAudioInputStream audioInputStream )
61.81 + {
61.82 + if( audioInputStream != null && audioInputStream.getLength() > 0)
61.83 + {
61.84 + format = audioInputStream.getFormat();
61.85 + byte[] audioBytes = null;
61.86 + try
61.87 + {
61.88 + audioBytes = new byte[audioInputStream.getLength()];
61.89 + audioInputStream.read(audioBytes);
61.90 + }
61.91 + catch( Exception ex )
61.92 + {
61.93 + ErrorManager.getDefault().notify(ex);
61.94 + return;
61.95 + }
61.96 +
61.97 + createWaveForm(audioBytes);
61.98 +
61.99 + try
61.100 + {
61.101 + audioInputStream.reset();
61.102 + }
61.103 + catch( IOException ex )
61.104 + {
61.105 + ErrorManager.getDefault().notify(ex);
61.106 + }
61.107 + }
61.108 + repaint();
61.109 + }
61.110 +
61.111 + private void createWaveForm(byte[] audioBytes)
61.112 + {
61.113 + m_dDuration = audioBytes.length /
61.114 + (double)format.getFrameSize() /
61.115 + format.getSampleRate();
61.116 + // round it off to the thousandths
61.117 + m_dDuration = (double)Math.round(1000f * m_dDuration) / 1000f;
61.118 +
61.119 + audioData = null; // clear the old audio data
61.120 + clearSelection();
61.121 +
61.122 + if (format.getSampleSizeInBits() == 16)
61.123 + {
61.124 + int iLengthInSamples = audioBytes.length / 2;
61.125 + audioData = new int[iLengthInSamples];
61.126 +
61.127 + if (format.isBigEndian())
61.128 + {
61.129 + for (int i = 0; i < iLengthInSamples; i++)
61.130 + {
61.131 + /* First byte is MSB (high order) */
61.132 + int MSB = audioBytes[2*i];
61.133 + /* Second byte is LSB (low order) */
61.134 + int LSB = audioBytes[2*i+1];
61.135 + audioData[i] = MSB << 8 | (255 & LSB);
61.136 + }
61.137 + }
61.138 + else
61.139 + {
61.140 + for (int i = 0; i < iLengthInSamples; i++)
61.141 + {
61.142 + /* First byte is LSB (low order) */
61.143 + int LSB = audioBytes[2*i];
61.144 + /* Second byte is MSB (high order) */
61.145 + int MSB = audioBytes[2*i+1];
61.146 + audioData[i] = MSB << 8 | (255 & LSB);
61.147 + }
61.148 + }
61.149 + }
61.150 + else if (format.getSampleSizeInBits() == 8)
61.151 + {
61.152 + int iLengthInSamples = audioBytes.length;
61.153 + audioData = new int[iLengthInSamples];
61.154 + if (format.getEncoding().toString().startsWith("PCM_SIGN"))
61.155 + {
61.156 + for (int i = 0; i < audioBytes.length; i++)
61.157 + {
61.158 + audioData[i] = audioBytes[i];
61.159 + }
61.160 + }
61.161 + else
61.162 + {
61.163 + for (int i = 0; i < audioBytes.length; i++)
61.164 + {
61.165 + audioData[i] = audioBytes[i] - 128;
61.166 + }
61.167 + }
61.168 + }
61.169 + }
61.170 +
61.171 + public boolean isRecording()
61.172 + {
61.173 + return m_bRecording;
61.174 + }
61.175 +
61.176 + public void setRecording(boolean b)
61.177 + {
61.178 + m_bRecording = b;
61.179 + }
61.180 +
61.181 + public void setCaptureLine(DataLine l)
61.182 + {
61.183 + m_captureLine = l;
61.184 + }
61.185 +
61.186 + public void setPlaybackLine(DataLine l)
61.187 + {
61.188 + m_playbackLine = l;
61.189 + }
61.190 +
61.191 + public String getErrorString()
61.192 + {
61.193 + return m_sError;
61.194 + }
61.195 +
61.196 + public int getSelectionStart()
61.197 + {
61.198 + return m_iSelectionStart;
61.199 + }
61.200 +
61.201 + public int getSelectionEnd()
61.202 + {
61.203 + return m_iSelectionEnd;
61.204 + }
61.205 +
61.206 + public void clearSelection()
61.207 + {
61.208 + m_iSelectionStart = m_iSelectionEnd = -1;
61.209 + }
61.210 +
61.211 +
61.212 + public void paint(Graphics g)
61.213 + {
61.214 + Dimension d = getSize();
61.215 + int w = d.width;
61.216 + int h = d.height;
61.217 + int INFOPAD = 15;
61.218 +
61.219 + List<Line2D> lines = new ArrayList<Line2D>();
61.220 + if (audioData != null && format != null)
61.221 + {
61.222 +
61.223 + int frames_per_pixel = (int)(m_dDuration * format.getSampleRate()) / w;
61.224 + byte my_byte = 0;
61.225 + double y_last = 0;
61.226 + for( double x=0; x < w; x++ )
61.227 + {
61.228 + int idx = (int) (frames_per_pixel * format.getChannels() * x);
61.229 + if( format.getSampleSizeInBits() == 8)
61.230 + {
61.231 + my_byte = (byte) audioData[idx];
61.232 + }
61.233 + else
61.234 + {
61.235 + my_byte = (byte) (128 * audioData[idx] / 32768);
61.236 + }
61.237 + double y_new = (h * (128 - my_byte) / 256);
61.238 + lines.add(new Line2D.Double(x, y_last, x, y_new));
61.239 + y_last = y_new;
61.240 + }
61.241 + }
61.242 +
61.243 + Graphics2D g2 = (Graphics2D) g;
61.244 + g2.setBackground(getBackground());
61.245 + g2.clearRect(0, 0, w, h);
61.246 + g2.setColor(Color.white);
61.247 + g2.fillRect(0, h-INFOPAD, w, INFOPAD);
61.248 +
61.249 + if (m_sError != null)
61.250 + {
61.251 + // Write out an error string instead of the wave form
61.252 +
61.253 + g2.setColor(s_jfcBlue);
61.254 + g2.setFont(new Font("serif", Font.BOLD, 18));
61.255 + g2.drawString("ERROR", 5, 20);
61.256 + AttributedString as = new AttributedString(m_sError);
61.257 + as.addAttribute(TextAttribute.FONT, s_font12, 0, m_sError.length());
61.258 + AttributedCharacterIterator aci = as.getIterator();
61.259 + FontRenderContext frc = g2.getFontRenderContext();
61.260 + LineBreakMeasurer lbm = new LineBreakMeasurer(aci, frc);
61.261 + float x = 5, y = 25;
61.262 + lbm.setPosition(0);
61.263 + while (lbm.getPosition() < m_sError.length()) {
61.264 + TextLayout tl = lbm.nextLayout(w-x-5);
61.265 + if (!tl.isLeftToRight()) {
61.266 + x = w - tl.getAdvance();
61.267 + }
61.268 + tl.draw(g2, x, y += tl.getAscent());
61.269 + y += tl.getDescent() + tl.getLeading();
61.270 + }
61.271 + }
61.272 + else if (isRecording())
61.273 + {
61.274 + // while recording, just write out the current length in big
61.275 + // characters in the middle of the graph
61.276 + g2.setColor(s_jfcBlue);
61.277 + g2.setFont(new Font("serif", Font.BOLD, 36));
61.278 + g2.drawString("Length: " + String.valueOf(m_dSeconds), 25, 50);
61.279 + }
61.280 + else
61.281 + {
61.282 + // write the length and position at the bottom
61.283 +
61.284 + g2.setColor(Color.black);
61.285 + g2.setFont(s_font12);
61.286 + g2.drawString("Length: " + String.valueOf(m_dDuration) + " Position: " + String.valueOf(m_dSeconds), 3, h-4);
61.287 +
61.288 + if (!lines.isEmpty()) {
61.289 + // .. render sampling graph ..
61.290 + g2.setColor(s_jfcBlue);
61.291 + for (int i = 1; i < lines.size(); i++) {
61.292 + g2.draw((Line2D) lines.get(i));
61.293 + }
61.294 +
61.295 + // .. draw current position ..
61.296 + if (m_dSeconds != 0) {
61.297 + double loc = m_dSeconds/m_dDuration*w;
61.298 + // if we're just playing a selection, we need to move to
61.299 + // the offset
61.300 + if( m_iSelectionStart != -1 )
61.301 + {
61.302 + loc += Math.min( m_iSelectionStart, m_iSelectionEnd );
61.303 + }
61.304 + g2.setColor(s_pink);
61.305 + g2.setStroke(new BasicStroke(3));
61.306 + g2.draw(new Line2D.Double(loc, 0, loc, h-INFOPAD-2));
61.307 + }
61.308 + }
61.309 +
61.310 + // draw the current selection
61.311 + if( m_iSelectionStart != -1 )
61.312 + {
61.313 + g2.setXORMode(Color.yellow);
61.314 + g2.fillRect( Math.min(m_iSelectionStart, m_iSelectionEnd),
61.315 + 0,
61.316 + Math.abs(m_iSelectionStart - m_iSelectionEnd),
61.317 + getHeight());
61.318 + }
61.319 + }
61.320 + }
61.321 +
61.322 + public void start()
61.323 + {
61.324 + m_thread = new Thread(this);
61.325 + m_thread.setName("SamplingGraph");
61.326 + m_thread.start();
61.327 + }
61.328 +
61.329 + public void stop()
61.330 + {
61.331 + if (m_thread != null)
61.332 + {
61.333 + m_thread.interrupt();
61.334 + }
61.335 + m_thread = null;
61.336 + }
61.337 +
61.338 + /**
61.339 + * Runs a line across the sample waveform during playback.
61.340 + */
61.341 + public void run()
61.342 + {
61.343 + m_dSeconds = 0;
61.344 + while (m_thread != null)
61.345 + {
61.346 + if ((m_playbackLine != null) && (m_playbackLine.isOpen()) )
61.347 + {
61.348 + long milliseconds = (m_playbackLine.getMicrosecondPosition() / 1000);
61.349 + m_dSeconds = milliseconds / 1000.0;
61.350 + }
61.351 + else if ( (m_captureLine != null) && (m_captureLine.isActive()) )
61.352 + {
61.353 + long milliseconds = (m_captureLine.getMicrosecondPosition() / 1000);
61.354 + m_dSeconds = milliseconds / 1000.0;
61.355 + }
61.356 +
61.357 + try { Thread.sleep(100); } catch (Exception e) { break; }
61.358 +
61.359 + repaint();
61.360 +
61.361 + while ((m_captureLine != null && !m_captureLine.isActive()) ||
61.362 + (m_playbackLine != null && !m_playbackLine.isOpen()))
61.363 + {
61.364 + try { Thread.sleep(10); } catch (Exception e) { break; }
61.365 + }
61.366 + }
61.367 + m_dSeconds = 0;
61.368 + repaint();
61.369 + }
61.370 +
61.371 + ////////////////// INNER CLASSES ///////////////////////////
61.372 + class MouseHandler extends javax.swing.event.MouseInputAdapter
61.373 + {
61.374 + public void mouseDragged( MouseEvent evt )
61.375 + {
61.376 + // Set the current selection
61.377 + if( m_iSelectionStart == -1 )
61.378 + {
61.379 + m_iSelectionStart = m_iSelectionEnd = evt.getX();
61.380 + }
61.381 + else
61.382 + {
61.383 + int x = evt.getX();
61.384 + if( x >= 0 && x <= SamplingGraph.this.getWidth() )
61.385 + {
61.386 + m_iSelectionEnd = x;
61.387 + }
61.388 + }
61.389 +
61.390 + SamplingGraph.this.repaint();
61.391 + }
61.392 +
61.393 + public void mousePressed( MouseEvent evt )
61.394 + {
61.395 + // clear the current selection
61.396 + SamplingGraph.this.clearSelection();
61.397 +
61.398 + SamplingGraph.this.repaint();
61.399 + }
61.400 + }
61.401 +
61.402 + //////////////////// INSTANCE VARIABLES ////////////////////
61.403 + private Thread m_thread;
61.404 +
61.405 + private double m_dDuration, m_dSeconds;
61.406 + private boolean m_bRecording = false;
61.407 + private DataLine m_captureLine, m_playbackLine;
61.408 + private String m_sError;
61.409 + private int m_iSelectionStart;
61.410 + private int m_iSelectionEnd;
61.411 + private int[] audioData;
61.412 + private AudioFormat format;
61.413 +
61.414 +
61.415 + //////////////////// CONSTANTS //////////////////////////////
61.416 + private static final Font s_font12 = new Font("serif", Font.PLAIN, 12);
61.417 + private static final Color s_jfcBlue = new Color(204, 204, 255);
61.418 + private static final Color s_pink = new Color(255, 175, 175);
61.419 +
61.420 +}
62.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
62.2 +++ b/platform/samples/AudioStation/wavutils/src/org/foo/wavutils/WrappedAudioInputStream.java Thu Nov 02 01:01:27 2006 +0000
62.3 @@ -0,0 +1,304 @@
62.4 +/*
62.5 + * The contents of this file are subject to the terms of the Common Development
62.6 + * and Distribution License (the License). You may not use this file except in
62.7 + * compliance with the License.
62.8 + *
62.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
62.10 + * or http://www.netbeans.org/cddl.txt.
62.11 + *
62.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
62.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
62.14 + * If applicable, add the following below the CDDL Header, with the fields
62.15 + * enclosed by brackets [] replaced by your own identifying information:
62.16 + * "Portions Copyrighted [year] [name of copyright owner]"
62.17 + */
62.18 +
62.19 +package org.foo.wavutils;
62.20 +/*
62.21 + * An AudioInputStream that wraps another stream, and can represent
62.22 + * a subset of the enclosed stream (for cropping purposes).
62.23 + *
62.24 + * When the stream is read, it begins at offset and reads only length
62.25 + * bytes of data, even if the enclosed stream may be longer. This provides
62.26 + * a convenient way to take an audio stream and crop it without having to
62.27 + * copy the underlying buffer.
62.28 + *
62.29 + * @author Rich Unger
62.30 + */
62.31 +
62.32 +import javax.sound.sampled.*;
62.33 +import java.io.*;
62.34 +
62.35 +public class WrappedAudioInputStream extends AudioInputStream
62.36 +{
62.37 + public WrappedAudioInputStream(AudioInputStream is, int length)
62.38 + {
62.39 + super(is, is.getFormat(), length); // this doesn't do anything,
62.40 + // as we'll be reading
62.41 + // from the wrapped stream
62.42 + wrappedStream = is;
62.43 + setLength(length);
62.44 + }
62.45 +
62.46 + public WrappedAudioInputStream(AudioInputStream is)
62.47 + {
62.48 + super(is, is.getFormat(), is.getFrameLength()); // this doesn't do
62.49 + // anything, as we'll
62.50 + // be reading from
62.51 + // the wrapped stream
62.52 + wrappedStream = is;
62.53 + setLength( (int)is.getFrameLength() * is.getFormat().getFrameSize() );
62.54 + }
62.55 +
62.56 + public void toFile(File file, AudioFormat format, AudioFileFormat.Type fileType) throws IOException
62.57 + {
62.58 + // convert to mu-law
62.59 + AudioInputStream ulawStream = AudioSystem.getAudioInputStream(format, this);
62.60 +
62.61 + OutputStream os = new FileOutputStream(file);
62.62 +
62.63 + try
62.64 + {
62.65 + AudioSystem.write(ulawStream, fileType, os);
62.66 + }
62.67 + finally
62.68 + {
62.69 + if (os != null)
62.70 + {
62.71 + os.close();
62.72 + }
62.73 + this.reset();
62.74 + }
62.75 + }
62.76 +
62.77 +
62.78 + /** Create a WrappedAudioInputStream from the given File. */
62.79 + public static WrappedAudioInputStream createFromFile(File promptFile)
62.80 + throws IOException, UnsupportedAudioFileException {
62.81 + if( promptFile == null ) {
62.82 + return null;
62.83 + }
62.84 +
62.85 + AudioInputStream ulawStream = null;
62.86 + try {
62.87 + // the input stream on the prompt file
62.88 + ulawStream = AudioSystem.getAudioInputStream( promptFile );
62.89 +
62.90 + // convert the stream to PCM
62.91 + if( !AudioSystem.isConversionSupported(
62.92 + Formats.INTERNAL_FORMAT, ulawStream.getFormat() ) )
62.93 + {
62.94 + throw new UnsupportedAudioFileException(
62.95 + "Cannot convert file of format " + ulawStream.getFormat() +
62.96 + " to " + Formats.INTERNAL_FORMAT);
62.97 + }
62.98 + return createFromUlawStream(ulawStream);
62.99 + } finally {
62.100 + // close the file (release file locks, etc)
62.101 + if( ulawStream != null ) {
62.102 + try {
62.103 + ulawStream.close();
62.104 + } catch( IOException ex ) {
62.105 + // print stack trace to ide.log
62.106 + ex.printStackTrace();
62.107 + }
62.108 + }
62.109 + }
62.110 + }
62.111 +
62.112 + /**
62.113 + * Convert the given mu-law stream to PCM, and return as a WrappedAudioInputStream.
62.114 + * Due to a bug in sun's javasound implementation, we must
62.115 + * read in the whole stream now, and deal with the audio data
62.116 + * post-conversion, rather than letting the conversion happen
62.117 + * lazily. Otherwise, the cropper will get conflicting information
62.118 + * about the sample size.
62.119 + */
62.120 + public static WrappedAudioInputStream createFromUlawStream(AudioInputStream ulawStream)
62.121 + throws IOException {
62.122 + AudioInputStream pcmStream = AudioSystem.getAudioInputStream(
62.123 + Formats.INTERNAL_FORMAT, ulawStream);
62.124 +
62.125 + // read the whole stream into memory before doing any conversions,
62.126 + // so we don't lock the file
62.127 + byte[] payload = new byte[(int)pcmStream.getFrameLength() *
62.128 + Formats.INTERNAL_FORMAT.getFrameSize()];
62.129 + pcmStream.read(payload);
62.130 + pcmStream = new AudioInputStream( new ByteArrayInputStream(payload),
62.131 + Formats.INTERNAL_FORMAT,
62.132 + pcmStream.getFrameLength() );
62.133 +
62.134 + return new WrappedAudioInputStream( pcmStream );
62.135 + }
62.136 +
62.137 +
62.138 + public WrappedAudioInputStream convert( AudioFormat newFormat )
62.139 + {
62.140 + AudioFormat oldFormat = getFormat();
62.141 +
62.142 + if( !AudioSystem.isConversionSupported( newFormat, oldFormat ) )
62.143 + {
62.144 + throw new IllegalArgumentException("Cannot convert file of format " +
62.145 + oldFormat + " to " + newFormat);
62.146 + }
62.147 + AudioInputStream newStream = AudioSystem.getAudioInputStream(
62.148 + newFormat, this);
62.149 +
62.150 + int iLength = getLength() / oldFormat.getFrameSize()
62.151 + * newFormat.getFrameSize();
62.152 +
62.153 + return new WrappedAudioInputStream( newStream, iLength );
62.154 + }
62.155 +
62.156 + public void crop( int offset, int length ) throws IOException
62.157 + {
62.158 + skip( offset );
62.159 + setLength(length);
62.160 + }
62.161 +
62.162 + public WrappedAudioInputStream normalize() throws IOException
62.163 + {
62.164 + int highSample = -1;
62.165 + int sample;
62.166 +
62.167 + // find the highest peak
62.168 + for( int i=0; i < getFrameLength(); i++ )
62.169 + {
62.170 + sample = Math.abs(readSample());
62.171 + highSample = sample > highSample ? sample : highSample;
62.172 + }
62.173 +
62.174 + // go back to the start of the stream
62.175 + reset();
62.176 +
62.177 + double ratio = (double) Short.MAX_VALUE / (double) highSample;
62.178 +
62.179 + ByteArrayOutputStream bytesOut = new ByteArrayOutputStream( getLength() );
62.180 + DataOutputStream out = new DataOutputStream( bytesOut );
62.181 +
62.182 + for( int i=0; i < getFrameLength(); i++ )
62.183 + {
62.184 + sample = readSample();
62.185 + out.writeShort( (short) (ratio * sample) );
62.186 + }
62.187 +
62.188 + AudioInputStream audioInputStream = new AudioInputStream(
62.189 + new ByteArrayInputStream( bytesOut.toByteArray() ),
62.190 + Formats.INTERNAL_FORMAT,
62.191 + getFrameLength() );
62.192 +
62.193 + return new WrappedAudioInputStream( audioInputStream );
62.194 + }
62.195 +
62.196 + final public void setLength(int i)
62.197 + {
62.198 + length = i;
62.199 + mark(i);
62.200 + }
62.201 +
62.202 + public int getLength()
62.203 + {
62.204 + return length;
62.205 + }
62.206 +
62.207 + public AudioFormat getFormat()
62.208 + {
62.209 + return wrappedStream.getFormat();
62.210 + }
62.211 +
62.212 + public long getFrameLength()
62.213 + {
62.214 + return length / getFormat().getFrameSize();
62.215 + }
62.216 +
62.217 + public int read() throws IOException
62.218 + {
62.219 + int n = wrappedStream.read();
62.220 + if( n != -1 )
62.221 + {
62.222 + offset++;
62.223 + }
62.224 + return n;
62.225 + }
62.226 +
62.227 + public int read( byte[] buf ) throws IOException
62.228 + {
62.229 + return read( buf, 0, buf.length );
62.230 + }
62.231 +
62.232 + public int read( byte[] buf, int off, int len ) throws IOException
62.233 + {
62.234 + // the "+1" is a hackish workaround for the fact
62.235 + // that audio input streams have a nasty habit
62.236 + // of leaving one byte on the stream, even for 8-bit audio
62.237 + if( offset + len + 1 >= length )
62.238 + {
62.239 + int n = wrappedStream.read(buf, off, length - offset);
62.240 +
62.241 + if( n != -1 )
62.242 + {
62.243 + offset += n;
62.244 + }
62.245 + return n;
62.246 + }
62.247 + else
62.248 + {
62.249 + int n = wrappedStream.read(buf, off, len);
62.250 +
62.251 + if( n != -1 )
62.252 + {
62.253 + offset += n;
62.254 + }
62.255 + return n;
62.256 + }
62.257 + }
62.258 +
62.259 + /** reads a single 16-bit, big-endian sample as a short */
62.260 + public short readSample() throws IOException
62.261 + {
62.262 + byte[] buf = new byte[2];
62.263 + read(buf);
62.264 + return (short)( ( (short)buf[0] << 8 ) + buf[1] );
62.265 + }
62.266 +
62.267 + public long skip( long n ) throws IOException
62.268 + {
62.269 + long retval = wrappedStream.skip(n);
62.270 + offset += (int)retval;
62.271 +
62.272 + return retval;
62.273 + }
62.274 +
62.275 + public int available() throws IOException
62.276 + {
62.277 + return length - offset;
62.278 + }
62.279 +
62.280 + public void close() throws IOException
62.281 + {
62.282 + wrappedStream.close();
62.283 + super.close();
62.284 + }
62.285 +
62.286 + final public void mark( int readLimit )
62.287 + {
62.288 + wrappedStream.mark(readLimit);
62.289 + offset = 0;
62.290 + }
62.291 +
62.292 + public void reset() throws IOException
62.293 + {
62.294 + wrappedStream.reset();
62.295 + offset = 0;
62.296 + }
62.297 +
62.298 + public boolean markSupported()
62.299 + {
62.300 + return wrappedStream.markSupported();
62.301 + }
62.302 +
62.303 + public AudioInputStream wrappedStream;
62.304 + private int length;
62.305 + public int offset;
62.306 +
62.307 +}
63.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
63.2 +++ b/platform/samples/AudioStation/wavutils/src/org/foo/wavutils/layer.xml Thu Nov 02 01:01:27 2006 +0000
63.3 @@ -0,0 +1,5 @@
63.4 +<?xml version="1.0" encoding="UTF-8"?>
63.5 +<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
63.6 +<filesystem>
63.7 +</filesystem>
63.8 +