Page 1 of 1

MIDI file writer or wav or ogg?

Posted: Sun Jan 20, 2019 10:12 am
by bloiiing
Hello, is there a library to create midi files, or wav files or ogg files in PB?

Thanks

Re: MIDI file writer or wav or ogg?

Posted: Sun Jan 20, 2019 1:39 pm
by infratec
Hi,

To save data as wav file, you have to use an own procedure.
But there are examples available. For example:

viewtopic.php?p=412988#p412988

MIDI Reader:
viewtopic.php?p=408596#p408596
viewtopic.php?p=71613#p71613

Also the file format of MIDI is not very complicated:
https://www.csie.ntu.edu.tw/~r92092/ref/midi/

Btw. you can load midi files directly via LoadMovie() ...
viewtopic.php?p=457492#p457492

Re: MIDI file writer or wav or ogg?

Posted: Sun Jan 20, 2019 2:00 pm
by bloiiing
Thank you for the link. I have this error: Structure not found: WAVEFORMATEX while trying to run the program. Perhaps you could say me why this error?

Thank you.

Re: MIDI file writer or wav or ogg?

Posted: Sun Jan 20, 2019 3:28 pm
by infratec
About which source code you are writing?
There are so many codes insided the links, it cost me simply to much time to check all of them. :wink:

Re: MIDI file writer or wav or ogg?

Posted: Sun Jan 20, 2019 4:01 pm
by bloiiing
infratec wrote:About which source code you are writing?
There are so many codes insided the links, it cost me simply to much time to check all of them. :wink:
I am sorry very much. The source code is the first you have given to me. viewtopic.php?p=412988#p412988

I don't know understand why the structure is not defined in this source... But I have seen the link to the midi file specifications and I think I will use this way.

Thank you very much.

Re: MIDI file writer or wav or ogg?

Posted: Sun Jan 20, 2019 4:04 pm
by Mijikai
bloiiing wrote:
infratec wrote:About which source code you are writing?
There are so many codes insided the links, it cost me simply to much time to check all of them. :wink:
I am sorry very much. The source code is the first you have given to me. viewtopic.php?p=412988#p412988

I don't know understand why the structure is not defined in this source... But I have seen the link to the midi file specifications and I think I will use this way.

Thank you very much.
I guess u are using a older version or the demo.

Add this and it should work:

Code: Select all

Structure WAVEFORMATEX
  wFormatTag.u
  nChannels.u
  nSamplesPerSec.l
  nAvgBytesPerSec.l
  nBlockAlign.u
  wBitsPerSample.u
  cbSize.u
EndStructure

Re: MIDI file writer or wav or ogg?

Posted: Mon Jan 21, 2019 11:25 am
by bloiiing
I guess u are using a older version or the demo.

Add this and it should work:

Code: Select all

Structure WAVEFORMATEX
  wFormatTag.u
  nChannels.u
  nSamplesPerSec.l
  nAvgBytesPerSec.l
  nBlockAlign.u
  wBitsPerSample.u
  cbSize.u
EndStructure
[/quote]

Thank you for the structure. But where can I find the new version of this demo? I am asking that because I have a new error: Constant not found: #WAVE_FORMAT_PCM. I am afraid to boring you with my questions...

Thank you.

Re: MIDI file writer or wav or ogg?

Posted: Mon Jan 21, 2019 11:57 am
by NicTheQuick
He guesses you are using the demo version of Purebasic. The demo version does not include any structures or constants from the Windows API. That the reason why the structur and constant can not be found.

Re: MIDI file writer or wav or ogg?

Posted: Mon Jan 21, 2019 12:36 pm
by bloiiing
NicTheQuick wrote:He guesses you are using the demo version of Purebasic. The demo version does not include any structures or constants from the Windows API. That the reason why the structur and constant can not be found.
Are you sure? Because I use the version that I have downloaded from my user account. I registered PB few years ago. And It works with others programs. But I have forgotten to say you that I am under Linux. I am going to try under windows and I will come back to let you know if it works.

Thank you.

Re: MIDI file writer or wav or ogg?

Posted: Mon Jan 21, 2019 12:50 pm
by bloiiing
bloiiing wrote:
NicTheQuick wrote:He guesses you are using the demo version of Purebasic. The demo version does not include any structures or constants from the Windows API. That the reason why the structur and constant can not be found.
Are you sure? Because I use the version that I have downloaded from my user account. I registered PB few years ago. And It works with others programs. But I have forgotten to say you that I am under Linux. I am going to try under windows and I will come back to let you know if it works.

Thank you.
I have just verified and it is the reason. It works fine on windows without changes. I had not seem there where windows constants.

Sorry an thanks you for your help.