-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #93 - handle negative millisecond length correctly in cue and s…
…kip implementations of Playable classes + just for completeness, I've fixed it in AudioSnippet even though loadSnippet is deprecated and I will be changing code so that a snippet will fail to load if the file length can't be determined
- Loading branch information
Showing
4 changed files
with
122 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package ddf.minim.tests; | ||
|
||
import ddf.minim.Minim; | ||
import ddf.minim.Playable; | ||
import ddf.minim.ugens.FilePlayer; | ||
|
||
/** | ||
* This test was created to ensure that audio files whose length is unknown are treated correctly by all API calls that use the length | ||
* | ||
* @see https://github.com/ddf/Minim/issues/93 | ||
* @author Damien Quartz | ||
* | ||
*/ | ||
public class UnknownFileLength extends TestBase | ||
{ | ||
|
||
public static void main(String[] args) | ||
{ | ||
Start(new UnknownFileLength(), args); | ||
} | ||
|
||
protected void setup(String[] args) | ||
{ | ||
// this is the test file noted in https://github.com/ddf/Minim/issues/73, which loads with an unknown length, | ||
// allowing us to ensure that several methods behave correctly under this condition. | ||
String fileName = "http://www.noiseaddicts.com/samples_1w72b820/2553.mp3"; | ||
|
||
testCueSkip( minim.loadFile(fileName) ); | ||
|
||
testCueSkip( new FilePlayer(minim.loadFileStream( fileName )) ); | ||
} | ||
|
||
void testCueSkip(Playable player) | ||
{ | ||
if (player != null) | ||
{ | ||
// should report -1, if it doesn't we need to use a different file | ||
Minim.debug( player.getMetaData().fileName() + " length: " + player.length() ); | ||
|
||
// should be ignored and report nothing | ||
player.cue( -1000 ); | ||
// debug should report skipping forward by 1000 milliseconds | ||
player.cue( 1000 ); | ||
|
||
// debug should report skipping forward by 1000 milliseconds to position 2000 | ||
player.skip( 1000 ); | ||
// debug should report skipping by -3000 milliseconds to position 0 | ||
player.skip( -3000 ); | ||
} | ||
} | ||
} |