Hello
First thank you for the new sdk and the example it contains.
i have a question about playing a sample. i suppose that the way to do that is to write in the buffer. my problem i need a function to read a file at the byte level to feed the buffer and it seems that there is no such a function in windows.h. I belive that C++ programmers use library like libsoundfile or OpenAL, but what about the use of library in usine ?
How to play a sound in a c++ module
-
martignasse
- Site Admin
- Posts: 611
- Location: Lyon, FRANCE
- Contact:
Hi Pansoul,
Happy to see you are around the SDK
Need some precisions about you'r question.
Do you want to play an external sound file (external from usine and loaded by code) ?
in this case, you effectively need to do it by yourself, as usine didn't expose this kind of functionality for now.
you can look at the stream C++ class, at binary section
or make it the C way with the FILE object and related functions.
Hope it help
PS : the wiki isn't updated for the new SDK version yet :/
but if you produce a nice simple example of loading external sound file, it should go in
Happy to see you are around the SDK
Need some precisions about you'r question.
Do you want to play an external sound file (external from usine and loaded by code) ?
in this case, you effectively need to do it by yourself, as usine didn't expose this kind of functionality for now.
you can look at the stream C++ class, at binary section
or make it the C way with the FILE object and related functions.
Hope it help
PS : the wiki isn't updated for the new SDK version yet :/
but if you produce a nice simple example of loading external sound file, it should go in
Martin FLEURENT - Usine Developer - SDK maintainer
right martignasse,
and also, the next version of the SDK will include a complete library to manage audio files and much more.
we are working on!
and also, the next version of the SDK will include a complete library to manage audio files and much more.
we are working on!
Olivier Sens
www.brainmodular.com
www.brainmodular.com
yes martignasse i try to read an external file load by code.
i load a wav 16 bits stereo file as a binary file and obtain list of char. i try to decode value i obtain ( from -128 to 127) using this format http://sub0.developpez.com/FormatWAV/FormatWAV.htm it works a little ( i mean not with all file)
so i don't know where is the problem (format file ? but all my files are 16 bits stereo) i transform the amplitude of sample into [-1; 1] interval to feed the buffer output using double precision variable. i suppose that it's the good way.
i will try others technics waiting for new sdk.
thanks
i load a wav 16 bits stereo file as a binary file and obtain list of char. i try to decode value i obtain ( from -128 to 127) using this format http://sub0.developpez.com/FormatWAV/FormatWAV.htm it works a little ( i mean not with all file)
so i don't know where is the problem (format file ? but all my files are 16 bits stereo) i transform the amplitude of sample into [-1; 1] interval to feed the buffer output using double precision variable. i suppose that it's the good way.
i will try others technics waiting for new sdk.
thanks
-128 to 127? It sounds that you're treating the file as 8-bit audio. In a 16 bit stereo file, every sample contains four bytes, two for left, two for right. I'm not quite sure about this, but if I've understood the little documentation I've checked on the net, uncompressed WAVs are "little-endian", that means that the least signicant byte comes before the most significant and with interleaved stereo the left side comes before the right.
Bjørn S
I decompress each octet as a char so it's normal to have value with a range of 256. To have 65535 directly with binary i would probably have to use WORD variable but i didn't succed with this variable. so i suppose that taking the most significant byte and multiplying it by 256 and adding it to the least significant i can obtain value with 65535.
Who is online
Users browsing this forum: No registered users and 4 guests
