public inbox for mauve-patches@sourceware.org
 help / color / mirror / Atom feed
* FYI: Sound test
@ 2007-07-05 23:02 Mario Torre
  2007-07-06  8:42 ` Mark Wielaard
  0 siblings, 1 reply; 2+ messages in thread
From: Mario Torre @ 2007-07-05 23:02 UTC (permalink / raw)
  To: mauve-patches; +Cc: Mark Wielaard

[-- Attachment #1: Type: text/plain, Size: 1259 bytes --]

I'm going to commit this patch that adds a mauve test for the Sound API.

The patch shown below is not the full commit, because it obviously lacks
the binary audio file.

The wave file comes from the k3b package from fedora 7, the package is
GPL, I guess the audio file is GPL/CC, but there is no reference of that
in the package (I assume same license as the package apply, but
ianal...)

If it turns out to be a proprietary file, I'll upload my 1,5 hour
today's experimental progressive noise session instead, so let's hope it
is not! :)

2007-07-06  Mario Torre  <neugens@limasoftware.net>

	* gnu/testlet/javax/sound/sampled/AudioProperties.java: 
	new file.
	* gnu/testlet/javax/sound/sampled/data/k3b_success1.wav: 
	new file. This is a binary audio file needed by the test.
	The file is from the k3b-1.0.1-1.fc7.2 package (fedora 7)

-- 
Lima Software - http://www.limasoftware.net/
GNU Classpath Developer - http://www.classpath.org/
Fedora Ambassador - http://fedoraproject.org/wiki/MarioTorre
Jabber: neugens@jabber.org
pgp key: http://subkeys.pgp.net/ PGP Key ID: 80F240CF
Fingerprint: BA39 9666 94EC 8B73 27FA  FC7C 4086 63E3 80F2 40CF

Please, support open standards:
http://opendocumentfellowship.org/petition/
http://www.nosoftwarepatents.com/

[-- Attachment #2: 2007-07-06-gsoc-mauve.patch --]
[-- Type: text/x-patch, Size: 4139 bytes --]

### Eclipse Workspace Patch 1.0
#P mauve
Index: gnu/testlet/javax/sound/sampled/AudioProperties.java
===================================================================
RCS file: gnu/testlet/javax/sound/sampled/AudioProperties.java
diff -N gnu/testlet/javax/sound/sampled/AudioProperties.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/sound/sampled/AudioProperties.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,117 @@
+/* AudioProperties.java -- simple test to read audio properties from
+   sound files.
+   Copyright (C) 2007 Mario Torre <neugens@limasoftware.net>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.4
+
+package gnu.testlet.javax.sound.sampled;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.sound.sampled.AudioFormat;
+import javax.sound.sampled.AudioInputStream;
+import javax.sound.sampled.AudioSystem;
+import javax.sound.sampled.UnsupportedAudioFileException;
+
+import gnu.testlet.ResourceNotFoundException;
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+/**
+ * @author Mario Torre <neugens@limasoftware.net>
+ */
+public class AudioProperties implements Testlet
+{
+  private static final String BASE_PATH =
+    "gnu#testlet#javax#sound#sampled#data#";
+  private static final String WAV = BASE_PATH + "k3b_success1.wav";
+  
+  protected TestHarness harness = null;
+
+  public void test(TestHarness harness)
+  {
+    this.harness = harness;
+    this.testWav();
+  }
+  
+  private void processWaveStream(AudioInputStream stream)
+  {
+    AudioFormat format = stream.getFormat();
+
+    // NOTE: we don't check for encoding, because our backend is unable
+    // to get the correct encoding as defined by AudioFormat.Encoding
+    // this is not a problem, because the encodings specified do not
+    // make sense in most cases.
+    this.harness.check(format.getFrameSize() == 1);        
+    this.harness.check(format.getChannels() == 1);
+    this.harness.check(format.getSampleRate() == 8000.0);
+    this.harness.check(format.getFrameRate() == 8000.0);
+    this.harness.check(format.getSampleSizeInBits() == 8);
+  }
+
+  /**
+   * Read a wav file and check if the expected properties match
+   * the actual result.
+   */
+  private void testWav()
+  {
+    this.harness.checkPoint("testWav()");
+    
+    File wav = null;
+    try
+      {
+        wav = this.harness.getResourceFile(WAV);
+      }
+    catch (ResourceNotFoundException e1)
+      {
+        this.harness.fail("ResourceNotFoundException: check the correct " +
+                          "input file location");
+        return;
+      }
+    
+    try
+      {
+        this.harness.checkPoint("testWav() - FILE");
+        AudioInputStream audioInputStream =
+          AudioSystem.getAudioInputStream(wav);
+        
+        processWaveStream(audioInputStream);
+        
+        this.harness.checkPoint("testWav() - STREAM");
+        AudioInputStream audioInputStream2 =
+          AudioSystem.getAudioInputStream(new FileInputStream(wav));
+        
+        processWaveStream(audioInputStream2);
+      }
+    catch (UnsupportedAudioFileException e)
+      {
+        this.harness.fail("Wave files should be supported by any" +
+                          " implementation");
+      }
+    catch (IOException e)
+      {
+        this.harness.fail("IOException: check the correct input file location");
+      }
+  }
+}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: FYI: Sound test
  2007-07-05 23:02 FYI: Sound test Mario Torre
@ 2007-07-06  8:42 ` Mark Wielaard
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2007-07-06  8:42 UTC (permalink / raw)
  To: Mario Torre; +Cc: mauve-patches

On Fri, 2007-07-06 at 01:00 +0200, Mario Torre wrote:
> I'm going to commit this patch that adds a mauve test for the Sound API.
> 
> The patch shown below is not the full commit, because it obviously lacks
> the binary audio file.
> 
> The wave file comes from the k3b package from fedora 7

Nice. Could you also add a little note to the README file about where
the files in gnu/testlet/javax/sound/sampled/data came from? That way it
is a little easier for people to find where each file came from (since
datafiles don't have a boilerplate header and not everybody goes through
the whole ChangeLog file).

Thanks,

Mark

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-07-06  8:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-05 23:02 FYI: Sound test Mario Torre
2007-07-06  8:42 ` Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).