Merging 2 Audio Files

Hello Community!

I just try to merge 2 audiofiles but i dont know what i am making wrong.

Every time i get a

NoProcessorException: Cannot find a Processor for: com.ibm.media.protocol.MergingPullDataSource@120cc56

Here is a part of my code:

MediaLocator audio1 =new MediaLocator("path to first audio file");

MediaLocator audio2 =new MediaLocator("path to second audio file");

try{

DataSource source1 = Manager.createDataSource(audio1);

DataSource source2 = Manager.createDataSource(audio2);

DataSource[] merge ={source1,source2};

DataSource mix = Manager.createMergingDataSource(merge);

Processor processor1 = Manager.createProcessor(mix);

}catch (Exception e){System.out.println(e);}

I hope someone can help me with my problem! I have no idea what i am making wrong!

thanks, morbion

[1232 byte] By [morbiona] at [2007-11-27 1:09:49]
# 1

Hi,

JMF is not well documented. I had the same problem. I don't know, what's your aim. If you only want play a merged file, you create for every datasource a processor. From these processors, you create datasources, which can be merged and added to a player.

If you want to work with the mixed audio data, you create a processor with the first datasource. Then look at this: http://forum.java.sun.com/thread.jspa?threadID=5146859&messageID=9548748#9548748.

You can add the other datasources to the ArrayList of the MyEffect constructor. But, they should have the same data format. If they don't have, you should call the process method(s) of the right codecs which you find at JMF Registry Editor->PlugIns->Codec. The documentation there is not always correct. If you want to know, if a special codec supports your format conversion, you should set the input format and ask for the supported output formats. P. ex. PCMToPCM doesn't support the conversion of the sample rate. For this you should use RateCvrt.

Regards,

Andreas

Andreas333a at 2007-7-11 23:45:07 > top of Java-index,Security,Cryptography...
# 2

thanks for your fast answer!

But why i should make a processor from both datasources and then from the processors datasources again!

datasource -> processor -> datasource

I dont know what you mean with it

the only way i can make a datasource from a processor is with

DataSource source1 = (DataSource)processor1;

and then i get a :

java.lang.ClassCastException: com.sun.media.processor.unknown.Handler cannot be cast to javax.media.protocol.DataSource

and my aim is to have 2 different .wave files(one backgroundmusic and one voice) for a musiconhold application for the asterisk voip server!

i had to mix the 2 files, and send it over a socket to the streamplayer from asterisk!

But i dont know how to mix the 2 audiofiles!

Regards,

morbion

morbiona at 2007-7-11 23:45:07 > top of Java-index,Security,Cryptography...
# 3

Hi,

at first, please read this http://java.sun.com/products/java-media/jmf/2.1.1/guide/index.html for the basics and the jmf api specifications for the Processor interface (http://java.sun.com/products/java-media/jmf/2.1.1/apidocs/javax/media/Processor.html). With the MyEffect class from my linked posting you will reach your aim.

About data sources: a datasource from a file is a pulldatasource. A datasource after a processor is a pushbufferdatasource. For more informations, look at the jmf specifications: http://java.sun.com/products/java-media/jmf/2.1.1/apidocs/overview-summary.html.

Regards,

Andreas

Andreas333a at 2007-7-11 23:45:07 > top of Java-index,Security,Cryptography...
# 4
ok thanks for your explanation! I will look at the links you posted and i hope i understand it :)regards,morbion
morbiona at 2007-7-11 23:45:07 > top of Java-index,Security,Cryptography...
# 5

hello andreas!

i am a little confused about the source code you posted but i have seen that you speak german! Can you maybe send me a mail? it would be easier for me because my englisch isnt the best and so i could ask you some things in german :)

my email addy is: webmaster@morb-design.at

thanks, morbion

morbiona at 2007-7-11 23:45:07 > top of Java-index,Security,Cryptography...
# 6

I do not know if there is any 'official policy' on this,

but I would prefer that you put the German version,

as well as your best English translation, to the forum.

That way, it might help people searching in future,

whether thay are native German speakers, native

English speakers, or speak ..Bengali (shrugs) at

home, but are fluent in German, or English!

(As an aside - I have had no problem understanding

your use of English - but I do not know the technical answer!)

Message was edited by:

AndrewThompson64

AndrewThompson64a at 2007-7-11 23:45:07 > top of Java-index,Security,Cryptography...
# 7

hehe my problem is the technical things.... andreas posted me a link how to merge 2 audio files!

But i am total new at java and i need it for the work. so its much easier to write in german but i dont think that it would be a good idea to write in german here...

when i have the solution i will post it here in englisch :)

morbiona at 2007-7-11 23:45:07 > top of Java-index,Security,Cryptography...