Author Topic: Playing a midifile with BassMidi & recording it as a wav file  (Read 747 times)

titobal

  • Posts: 11
Hello,

Is it possible to play a midifile with bassmidi and record what is played while playing it in a wav file ? (like routing the midifile with soundfont playback to a wav file)

If yes, is it possible to do it "silently" = i don't have to hear the midifile playing but I want to have its playback in a wav file ?

It is possible to do it a "twin speed" like the old tape recorders (with speed dubbing) ?

Thanks for all !
« Last Edit: 29 Jan '19 - 09:07 by titobal »

Ian @ un4seen

  • Administrator
  • Posts: 21991
Yes, you can write a MIDI stream to a WAV file during playback or without playing at all. The easiest way to do that is to use the BASSenc add-on, ie. BASS_Encode_Start with the BASS_ENCODE_PCM flag. To write the WAV file without playing, you need to make the MIDI stream a "decoding channel" by using the BASS_STREAM_DECODE flag on it, and then repeatedly call BASS_ChannelGetData to process it until you reach the end. A demonstration of doing this can be found in the CONTEST example that's included in the BASSenc package.

titobal

  • Posts: 11
Super Ian thanks,

any possibility to speed up the recording time or it has to wait the full time of the midi stream ?

Thanks a bunch.

Ian @ un4seen

  • Administrator
  • Posts: 21991
When using the "decoding channel" method, the processing speed will depend on how you call BASS_ChannelGetData. If you repeatedly call it without any delay, then the processing will be as fast as possible.

Francisco

  • Guest
Hi!

I can see that the mentioned example (for the macOS side) links against the deprecated (and not advisable for production on current hardware / deployment) Carbon.framework (C based).

Does un4seen has a bassenc example that works using the modern Cocoa framework? (64 bits deployment)

Thank you!

Francisco

Ian @ un4seen

  • Administrator
  • Posts: 21991
Unfortunately, there aren't currently any Cocoa examples but the BASS calls are basically the same in any language/framework, so you could take those parts from the examples into your own code.

Francisco

  • Guest
Hi again Ian,

About this procedure, I would like to set a default Volume, Reberv and Chorus value so they are applied during the export process (without playing the file). How would be the best way to achieve this? Any hint?

Thank you so much in advance,

Francisco

Ian @ un4seen

  • Administrator
  • Posts: 21991
When you say "default", do you mean in the case that the MIDI file doesn't set those things itself? If so, you can set the MIDI_EVENT_MASTERVOL / MIDI_EVENT_REVERB_LEVEL / MIDI_EVENT_CHORUS_LEVEL events via BASS_MIDI_StreamEvent before you start processing the MIDI stream. You can also override the MIDI file's events (so that yours are maintained) but that is a bit more complicated. If you are interested in doing that, you can do so with a MIDIFILTERPROC callback function (set via BASS_MIDI_StreamSetFilter). Please see the MIDIFILTERPROC documentation for details.