How to embed control change commands inside of a MIDI file - midi

I am making a simple game in order to learn a new language. I am in the process of collecting some music for the game and would like to use the MIDI format so that I can control the flow of the track (i.e., I would like to have an introduction that only plays once and does not play again when the song loops.)
I am having a tough time finding information on how to modify existing MIDI files so that they may send a control change signal to the synthesizer. Has anyone had experience with this?
I think that I should have been more clear with my original question. I am using an existing game engine which takes care of playing the music. I am under the impression that this control change value must be embedded directly in the MIDI file itself as I have no control over the synthesizer. From the manual:
MIDI files are played via the
DirectMusic Synthesizer. If a BGM MIDI
file contains the control change value
111, that value is recognized as where
the song will start repeating after it
reaches the end.
I wish I could do it programmatically. I suppose what I am after here is some sort of editor which will allow me to modify the MIDI file that I already have.

Sounds like what you really want is a midi editor

try looking in the Midi 1.0 spec
Here's a table of the control change messages though it looks like you're looking for a way to do this in software. yes?
you could try just sending it as raw midi data (ie. the messages on that table)
looking over your question again... my answer is not that useful...
what I would do if I were you is separate the introduction into it's own file and then you have a file containing just what you want to loop.
you could also look at the spec for the Standard Midi File format (SMF)

DirectMusicProducer is probably your best free option if you are playing using DirectMusic. I don't believe the MIDI record feature will include control changes, but your engine may support playing segment files which are much more flexible.
The only MIDI sequencer I use cost around $300 (USD) about 10 years ago (and no longer appears to exist), but I am not aware of any good quality free MIDI file sequencers. (Note that "MIDI editor" is probably different to "MIDI file editor" or "MIDI sequencer")

Related

use ID3 tag to collect information

I'm playing around with a .mp3 file and I'd like to imbed some code that prompts the listener for information (i was thinking a javascript popup) when the file is played. I've been reading up on ID3 tags and there seems to be some neat functionality built into the 'Audio Encryption' or possibly into the 'Generate Encapsulate Object' frames, but I cannot seem to find any good examples. I am assuming that if the tags can contain links I should be able to collect some data when the file is played.
No, ID3 in general does not support this. Only ID3v2, i.e. in versions 2.3.0 and 2.4.0 you could use
a WXXX frame, see https://id3.org/id3v2.3.0#User_defined_URL_link_frame while
a GEOB frame you might mean is more like an attachment for files, see https://id3.org/id3v2.3.0#General_encapsulated_object
How you're able to extract frames (let alone ID3v2 in general) out of an MP3 file with JavaScript is another problem.

how to record the voip call using sipsorcery sdk?

I am using sample programs provided by sipsorcery:
https://github.com/sipsorcery/sipsorcery/tree/master/sipsorcery-softphonev2
What I want to record the call or record the part of one side spoken text, process it, then generate the answer test and speak it back.
What I need right now to process the spoken text. I wanted to record the parts of call and save them to a wav file and generate text from it. but it seems to me that I am doing wrong. I am not able to generate the correct wav file using the provided method of sipsorcery SDK.
I have tried to follow the example on this forum as well, but it didn't work
https://markheath.net/post/how-to-record-and-play-audio-at-same
I expect that this should work using a small temporary wave file at each time the user speaks a sentence and response back again playing back the processed response file.
Any guidance how can I achieve this sense of interception and processing of the call?
Thanks,
Vivek
This example should be pretty close to what you need. It plays the audio (only ulaw support) via the default speaker using NAudio. To record it should be a matter of switching from using NAudio playback to saving to a wav file.

Record audio, add effects, then save result to a audio file

I am having trouble doing what the title said. My goal is to be able to add any desired effects to your recording, save the modified audio, then send that to a server.
I have searched the fourms and came across these threads:
viewtopic.php?f=7&t=13029&p=45362&hilit=saving#p45362
viewtopic.php?f=7&t=12660&p=44586&hilit=saving#p44586
viewtopic.php?f=7&t=13178&p=45746&hilit=saving#p45746
After reading those, I see it is possible to save the modified audio, but can it only be saved as a wav? Like I said after it is saved it will be sent to a server, so size is a big deal and wavs are relatively big compared to other formats. Ignoring that fact, I tried to implement FMOD_OUTPUTTYPE_WAVWRITER and I cannot get that to work; are there any good examples of using it? I looked though the examples in the library but I didn't see any..
But the basic structure of the app is to record, turn some switches off and on to see what filters you want, preview it, then press a button "Save" that will save it. What would this save function consist of?
Any help appreciated, thanks.
Using FMOD_OUTPUTTYPE_WAVWRITER is fairly straight forward, you set the type via System::setOutput, specify the output file via System::init extradriverdata. The extradriverdata should be an absolute path to a writable area of the device such as the documents directory. After you have finished playing, call System::release and the file will be complete.
The other option for recording wave data with effects is by creating a custom DSP and connecting it to the channel playing the recorded data. You will then get regular callbacks giving you float data that you must write out to disk yourself. You can find examples of DSPs and writing wav files in the dsp_custom and recordtodisk examples respectively.
Finally note that FMOD doesn't come with the facility to write compressed audio to disk, you will need another API to achieve this goal.
You can save as an AAC file via the ExtAudioFile API.

Take screenshot of audio stream

Alright, what I need is a command-line application that allows you to take a screenshot of a file's audio stream.
For example it should be run like this:
app.exe "C:/artist-title.mp3" "C:/mp3Stream.jpg"
app.exe "C:/artist-title.wav" "C:/wavStream.jpg"
It only has to be able to capture mp3 streams, other streams are a bonus.
Preferably all audio channels are listed in the image, but if all channels are combined into one mono stream it would work just as good for me.
So, is there such a application out there? So that I don't re-invent the wheel.
If not does anyone have tips on how I should go about writing such a application myself? Preferably in Java. I can handle programming pretty well but I'm not exactly an expert on the MP3/WAV formats.
Why do I need it...? Well, it's more fun to link to a file online with some sort of preview image besides the link. It gives you a hint of the audio character before you listen to it (is it loud? does it look like "bit music"? does it have any parts that are more quiet than others? etc).
Never mind, I wrote my own little application in Java.
It was a piece of cake once I found this excellent guide:
http://codeidol.com/java/swing/Audio/Build-an-Audio-Waveform-Display/
Although you can't download the source from that page (as far as I can tell, though he makes it apparent that you should be able to) he does provide some very useful key lines of code that makes it easy to puzzle together the application.
Adding a little bit of help (easy stuff). You can get a graphics object from doing so:
BufferedImage img = new BufferedImage(500, 100, BufferedImage.TYPE_INT_RGB);
Graphics2D gfx = (Graphics2D) img.getGraphics();
And once you have drawn everything you need on the gfx you can save it to disk just by one line:
ImageIO.write(img, "jpg", new File("waveform.png"));
It's hard to get it to look very good though. Doesn't look as nice as for example Audacity. Guess they have spent more time on it than a few hours though.
The biggest pain about this is however that Java don't support MP3 import. They really should get around to that.
So to get the waveform of MP3s I first convert them into WAV using "javazoom.jl.decoder.Decoder.java", it's on their website. Very easy to use, just give the input path and the output path and it's done.
javazoom dot net (couldn't post more than one "hyperlink" on this website)
The big downside of this is of course that a huuge WAV file has to be created, and woe be unto thee if the MP3 happens to be 15 minutes or so... The WAV will be over 100 MiB (maybe even 200 MiB, haven't found out since I got a Java-out-of-memory-error, even though I gave the VM 512mb).
MP3 support in Java today please. Guess the reason they don't have it is because of copyright issues. Copyright really is slowing man down.
Also take a look at http://www.jsresources.org/
It provides a pretty good FAQ section about everything Audio in Java, and some example applications.

rendering a waveform on an iphone

I was wondering if anyone has any suggestions on how to go about rendering a waveform of an audio file. I wold like to enable the user to set an in and out point of an audio track and I need to have a waveform so you can see where to put the points.
Are there any libraries available for this or does it need to be a completely custom solution?
Is it even called a waveform ? Maybe there's a better word for it so I can do some more searching.
TIA !
I'm reposting my answer from this question, since it applies here as well:
When displaying an audio waveform, you will want to do some sort of data reduction on the original data, because there is usually more data available in an audio file than pixels on the screen. Most audio editors build a separate file (called a peak file or overview file) which stores a subset of the audio data (usually the peaks and valleys of a waveform) for use at different zoom levels. Then as you zoom in past a certain point you start referencing the raw audio data itself.
Here are some good articles on this:
Waveform Display
As far as source code goes, I would recommend looking through the Audacity source code. Audacity's waveform display is pretty good and mostly likely does a similar sort of data reduction when rendering the waveforms.
CorePlot is the library you are looking for. It is hosted on Google code.
See this related SO question.
I realise this is an old post, however i searched for this recently, and decided to roll my own solution based on a few snippets i located on SO and a few other sites.
See my answer to This question