I'm currently attempting to concatenate several wave files into a single wave
file using java with ColdFusion. I am using the java code here -
http://stackoverflow.com/questions/653861/join-two-wav-files-from-java - as a
basis for my ColdFusion cfscript code below (apologies for formatting in
advance):
<cfscript>
strLocation = #getDirectoryFromPath(getCurrentTemplatePath())# & 'wavs\';
aWav = [#strLocation# & "test1.wav",#strLocation# & "test2.wav"];
aAudioObj = ArrayNew(1);
SequenceInputStream = createObject("java","java.io.SequenceInputStream");
AudioFileFormat = createObject("java","javax.sound.sampled.AudioFileFormat");
AudioInputStream = createObject("java","javax.sound.sampled.AudioInputStream");
AudioSystem = createObject("java","javax.sound.sampled.AudioSystem");
//loop through and create java file objects for each item in the array
for(i=1; i lte ArrayLen(aWav); i = i + 1) {
aAudioObj[i] =
AudioSystem.getAudioInputStream(createObject("java","java.io.File").init(aWav[i]));
}
fileNew = createObject("java","javax.sound.sampled.AudioInputStream").init(
createObject("java","java.io.SequenceInputStream").init(aAudioObj[1],aAudioObj[2]),
aAudioObj[1].getFormat(),
aAudioObj[1].getFrameLength() + aAudioObj[2].getFrameLength()
);
AudioSystem.write(
fileNew,
AudioFileFormat.Type.WAVE,
createObject("java","java.io.File").init("#strLocation#concat1.wav")
);
</cfscript>
Stepping through the code things are going swimmingly until I attempt to write
the newly created wave file back to the file system. Specifically, the
"AudioFileFormat.Type.WAVE" line throws the error:
"The system has attempted to use an undefined value, which usually indicates a
programming error, either in your code or some system code.
Null Pointers are another name for undefined values. "
Dumping the available methods on AudioFileFormat and putting around the
javadocs seems to imply that "Type.WAVE" is a static property, which I
understand CF can have problems accessing??
How do I define an AudioFileFormat of type WAVE?
* Thanks in Advance -
Matthew Reinbold
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know
on the House of Fusion mailing lists
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:322922
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4