Import midi to AVI file

A

ahjiang

Hi all,

Is it possible to use Java Media Framework to import a midi file into
an existing AVI file?

Appreciate any inputs.
 
A

Andrew T.

Is it possible to use Java Media Framework to import a midi file into
an existing AVI file?

Do you mean
a) Play the MIDI at the same time as the AVI. 'attach' it at
runtime as the soundtrack for the AVI?
b) Write the AVI file to disk with the MIDI file attached as a
soundtrack?

a) is fairly east, but for b)...
Maybe, but you have some challenges ahead.

1. A MIDI tune generates no sampled audio signal (on my
PC) so this is one PC that would require a loop-back before it
was even possible to detect the audio signal generated by the
notes.

2. The MIDI synthesizers of different PC's will produce different
sounds, so you cannot expect any two sound cards to generate
the tune quite the same way.

I recommend breaking this problem into parts if you intend
to pursue it. On the one hand check that you can merge
a sampled sound file into an AVI as the soundtrack (requires
JMF), on the other check that you can obtain a MIDI sequence
as a sound signal (core J2SE).

HTH

Andrew T.
 
A

ahjiang

Andrew said:
b) Write the AVI file to disk with the MIDI file attached as a
soundtrack?


1. A MIDI tune generates no sampled audio signal (on my
PC) so this is one PC that would require a loop-back before it
was even possible to detect the audio signal generated by the
notes.

2. The MIDI synthesizers of different PC's will produce different
sounds, so you cannot expect any two sound cards to generate
the tune quite the same way.

I recommend breaking this problem into parts if you intend
to pursue it. On the one hand check that you can merge
a sampled sound file into an AVI as the soundtrack (requires
JMF), on the other check that you can obtain a MIDI sequence
as a sound signal (core J2SE).

I would need to import the midi file into the avi file as a soundtrack
without using the player or so.

If a midi sequence can be obtain as a sound signal, how would that help
in importing into the avi file?
 
A

Andrew T.

...
I would need to import the midi file into the avi file as a soundtrack
without using the player or so.

I think I understand.
If a midi sequence can be obtain as a sound signal, how would that help
in importing into the avi file?

MIDI is like a musical score, it stores the notes, not the
sound of the notes.

Only sampled sound can be stored in the more common
sound formats such as those used by AVI or MOV videos.

To store a MIDI into the soundtrack of a video, you first
need to convert it to a sampled sound.

Andrew T.
 
A

ahjiang

Thanks for the advice on the sound signal. So even if midi can't work,
just forcefully allow wav files.

The other problem would be much tougher. I have no idea how to open up
the avi file as a stream in Java and putting music in it. Will need to
look further into this issue.
 
A

Andrew T.

Thanks for the advice on the sound signal. So even if midi can't work,
just forcefully allow wav files.

? I do not understand what you mean by 'forcefully', but
WAV files, as well as AU files are 'sampled sound' files.

If you can convert your MIDI to either of those types of
sampled sound format (or some other type*), I suspect
you have the major part of the task done.

* I mentioned AU and WAV because core Java understands
them. But if you add the JMF, that opens up a lot more
formats.

That being said, if you want to continue with the MIDI's,
I think you should at first stick to AU's or WAVs and core
J2SE, notably packages javax.sound.sampled &
javax.sound.midi.
The other problem would be much tougher. I have no idea how to open up
the avi file as a stream in Java and putting music in it. Will need to
look further into this issue.

That is where the JMF comes in - in fact, if MIDI is
unimportant and you just want 'sound in your AVI'
you should go straight to the JMF.

Then you can use any old WAV or AU (or MP3..) and try
stitching it in as the soundtrack of an existing AVI.

I have not used the JMF much, beyond playing with
JMStudio (which was quite handy recently in helping
me strip the soundtrack *out* of MOV files!).

By the way - please trim earlier words that are not needed,
and put your comments in-between the earlier words that
*are* needed (as I did above).

'In-line' posting makes threads much easier to understand.

HTH

Andrew T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top