使用软件合成器转换MIDI文件到原始音频 [英] Converting MIDI file to raw audio using a software synth

查看:252
本文介绍了使用软件合成器转换MIDI文件到原始音频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图动态地直接从我的Andr​​oid应用程序产生一个小的MP4音频+视频文件。

I'm trying to dynamically generate a small MP4 audio+video file directly from my Android app.

我原来的进攻计划:

  1. 用户输入一些基本的乐曲数据(一个和弦等)和应用程序建立一个MIDI文件。

  1. The user enters some basic song data (a chord progression, etc) and the app builds a MIDI file.

该系统建立的和弦图表为每个和弦,并使用MIDI阅读它生成的动画帧阵列是定时到MIDI

The system builds chord diagrams for each chord, and using a MIDI reader it generates the animations frames array that is timed to the MIDI

转换的MIDI成原始的PCM音频数据< - 这太问题是,具体到这一点

Convert the MIDI into a raw PCM audio data <-- this S.O. question is specific to this point

应用原始音频的动画帧 - 和连接code中的音频和视频帧转换为MP4

Apply the raw audio to the animation frames - and encode the audio and video frames into an MP4

提供所产生的MP4视频与标准的播放控件用户。

Provide the resulting MP4 video to the user with standard playback controls.

的应用程序已经建立了基于用户输入,包括速度,仪器,笔记等,这部分是很容易完成,MIDI文件被正确生成MIDI文件。这个MIDI从Android的MediaPlayer的正常播放。 (步骤1)

The App already builds the MIDI file based on user inputs including tempo, instrument, notes, etc. This part is done easily and the MIDI file is being generated correctly. This MIDI plays fine from Android's MediaPlayer. (step 1)

动画帧也被正确通过回读MIDI文件和交叉引用的静态位图的列表的序列中的每个和弦创建。这些帧将成为视频等,但是将不带音频在第一。 (步骤2)

The animation frames are also being created correctly by reading back the MIDI file and cross referencing a list of static bitmaps for each chord in the sequence. These frames will become the video... but will be without audio at first. (step 2)

正如你所看到的,存在的问题与Android MIDI延迟与其说是一个问题,对我来说,因为我不是创建一个实时的合成应用程序......我只是想将MIDI转换为某种音频格式,可以然后混入一个已经定时以原始将MIDI一个视频。 (步骤3)

As you can see, the problems with Android MIDI latency is not so much a problem for me because I'm not creating a real-time synthesizer App... I just want to convert the MIDI to some audio format that can then be mixed into a video that is already timed to original the MIDI. (step 3)

我遇到的问题是第3步。

The problem I'm running into is Step 3.

我知道我需要使用的软件MIDI合成来获得,将被从MIDI事件序列产生的实际音频输出。不过,得到这个才能正常工作已成为一个主要障碍。我不关心所产生的声音的precise质量,只是它紧密地匹配到什么人会想到,如果他们使用通用MIDI采样从一般的设备,其中(ALA肌无力音色库或发现了,在Sovinox声音等)

I understand that I need to use a software MIDI synthesizer to obtain the actual audio output that would be produced from a sequence of MIDI events. However, getting this to work correctly has become a major hurdle. I do not care about the precise quality of the resulting audio, just that it matches closely to what someone would expect if they where using General MIDI samples from a generic device (ala Gravis soundfonts or bulit-in Sovinox sounds, etc).

所以...

  1. Android的MIDI库

采用Android MIDI驱动Sonivox EAS库

我的第一次尝试是与上述两个项目......混搭他们在这样一种方式,MIDI文件可以被转换成原始的PCM数据缓冲区....它一直没有去这么好还。

My first attempt was with the above two projects... mash them up in such a way that a MIDI file could be converted into a raw PCM data buffer.... it hasn't gone so well yet.

将MIDI库(1)读出与一个实时监听一个MIDI文件并发送事件到MIDI驱动器(2),它起着由机载合成器产生的原始PCM数据。

The midi library (1) reads a MIDI file with a real-time listener and sends the events to the Midi Driver (2) which plays the raw PCM data generated by the onboard synthesizer.

(注:A几个调整分别向驾驶员提出,使整个缓冲储存且仅返回一次将MIDI读者结束这也意味着,整个过程需要的时间量等于所述歌曲的长度只转换是因为我们在监听实时。)

(NOTE: A few tweaks were made to the driver so that the entire buffer was stored and only returned once the MIDI reader was finished. This also means that the entire process takes an amount of time equal to length of the song just to convert it because we are "listening" in real-time.)

我还没有得到这个工作,因为我所希望的。我想保持这种尽可能简单和preFER如果在所有可能使用的开源项目。这将是更好,如果能做到这一点不依赖于实时监听。

I have yet to get this to work as I hoped. I wanted to keep this as simple as possible and prefer to use open source projects if at all possible. It would be better if it could do this without relying on real-time listeners.

其他的一些库和工具,我一直在考虑(但可能是矫枉过正):

Some other libraries and tools that I have been considering (but may be overkill):

  1. 纯数据库的Andr​​oid

MidiSheetMusic应用程序(带源)

合成工具包中的C ++(STK)

音乐合成器Android版

深红软合成器

更竞争者(没有太多的研究尚未完成):

EVEN MORE CONTENDERS (not much research done yet):

jFugue/timidity/audacity/fluidSynth/cSound/jMusic/JSyn/Gervill/Softonic/Caustic/LibGDX/JetPlayer/OpenSL-ES

jFugue/timidity/audacity/fluidSynth/cSound/jMusic/JSyn/Gervill/Softonic/Caustic/LibGDX/JetPlayer/OpenSL-ES

我的问题是:

  • 我是工作沿着正确的方向与上述项目?我是比较新的MIDI-> PCM转换,所以我要确保我不是完全失去了一些东西。

  • Am I working down the correct path with the above projects? I'm relatively new to MIDI->PCM conversion so I want to make sure I'm not completely missing something.

如果不是这样,我应该如何去转换MIDI文件转换成某种音频格式,然后可以在建立一个MP4(或任何视频播放格式)中使用?

If not, how should I go about converting a MIDI file into some sort of audio format that can then be used in the creation of an MP4 (or any video playback format)?

是否有可能在采用Android将MIDI 2原始音频波形,这个任务有帮助的其他开源项目?

Are there other open source projects that may be helpful in this task of converting MIDI 2 raw audio waveforms using Android?

和有没有使用已经写在Android这样的任务的任何例子吗? (即已经移植了与Android JNI等使用)

And are there any examples of such a task already written for use on Android? (i.e. already ported for use with Android JNI, etc)

我的希望是,我完全错过了什么,这将使这是一个简单的任务......我的假设是,这是要采取一些严重的黑客攻击和JNI功夫。

My hope is that I completely missed something that will make this a trivial task... my assumption is that this is going to take some serious hacking and JNI kung-fu.

我愿意采取坚硬的路面上,如果这是什么需要。任何和所有的建议是AP preciated。

I am open to taking the hard road if that's what it takes. Any and all advice would be appreciated.

推荐答案

我不是一个Android用户,但我试过很多方法可以从MIDI生成WAV文件,我更高兴这项任务,与FluidSynth ,这似乎是可以作为Android的图书​​馆,并且是这个其他的StackOverflow问题点:使用Fluidsynth到从的SoundFonts演奏音符Android的

I'm not an Android user, but I tried many ways to generate WAV files from MIDI, and I'm the more happy about this task, with FluidSynth, which seems to be available as a library for Android, and is the point of this other StackOverflow question: Using Fluidsynth to play notes from SoundFonts on Android.

您只需要知道声音的字体(在网上搜索会轻易告诉你),然后选择一个好的这是不是太大(否则,你可能有内存不足问题)。

You just need to know about sound‑fonts (searching the web will easily tell you) and choose a good one which is not too big (otherwise, you may have lack of memory issue).

另外,还要检查声音字体涵盖了所有你想要播放的工具。

Also check the sound‑font covers all the instruments you want to be playable.

这篇关于使用软件合成器转换MIDI文件到原始音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆