Welcome to %s forums

BrainModular Users Forum

Login Register

Audiofile

Create your own modules in C++
Post Reply
User avatar
oli_lab
Member
Posts: 1241
Location: Brittany, France
Contact:

Audiofile

Unread post by oli_lab » 05 May 2025, 19:33

Hi,
I'm trying to use the "audiofile" class in the SDK to make a multitrack file but I get some errors :
My idea is to have a multitrack wave file that I can save (or load) and populate it with samples
But I think I get something wrong.
If I want to have a recorder like the "audios ampler recorder" module, do I have to save the samples in a buffer (RAM) and then use the audiofile to save the wave file to disk ?
I'm a bit lost in here.

in .h

TAudioFilePtr audiofile1;

in .cpp

// constructor
multitrackrecorder::multitrackrecorder()

{
audiofile1 = sdkCreateAudioFile();
}

....

//-----------------------------------------------------------------------------
// initialisation
void multitrackrecorder::onInitModule (TMasterInfo* pMasterInfo, TModuleInfo* pModuleInfo)
{
sdkSetChannelsAudioFile(audiofile1, numOfAudiotInsOuts);
sdkSetSizeAudioFile(audiofile1, 60 * sdkGetSampleRate());

}

When loaded in Usine, I get those error messages :
[4] Error :
bad pointer in SetChannelsAudioFile
[6] Error :
bad pointer in SetSizeAudioFile

any idea ?
thanks
http://oli-lab.org

Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces

follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social

User avatar
oli_lab
Member
Posts: 1241
Location: Brittany, France
Contact:

Unread post by oli_lab » 20 May 2025, 14:55

Finally I will make some code from scratch with ofstream direct in C++ so I will be able to adress the metata datas in the wave file as well.

wish me luck

Olivar
http://oli-lab.org

Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces

follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social

User avatar
oli_lab
Member
Posts: 1241
Location: Brittany, France
Contact:

Unread post by oli_lab » 18 Jan 2026, 22:11

Hi,
I had a go with the audiofile command las few days.
I managed to load wav files, but can't save any

here is the part of the code that's not working : (it's included in a function that is called at callback)

Code: Select all

	for (int i = 0; i < m_size; ++i) {
		sdkSetSampleAudioFile(audioFile, 1,i, m_buffer[i]);
	}
	sdkSetChannelsAudioFile(audioFile, 1);
	sdkSetSizeAudioFile(audioFile, m_size);
	sdkSaveToDiskAudioFile(audioFile, tempChar, 1);
	}
/////////////////////////////
if I run it, it will return errors :
[2] Error :
[HydroGen OP V5] CallBack, paramIndex=19

///////////////////////////////////////
tried with

sdkSetChannelsAudioFile(audioFile, 1);
sdkSetSizeAudioFile(audioFile, m_size);
before
for (int i = 0; i < m_size; ++i) {
sdkSetSampleAudioFile(audioFile, 1,i, m_buffer);

same thing
/////////////////////////////////////////

if I comment it and run only SetChannelsAudioFile and SetSizeAudioFile :

[6] Error :
bad pointer in SetChannelsAudioFile
[8] Error :
bad pointer in SetSizeAudioFile

//////////////////

with only: sdkSetSampleAudioFile(audioFile, 1,i, m_buffer);

[2] Error :
[HydroGen OP V5] CallBack, paramIndex=19


/////////////////////////////////////
with only: sdkSaveToDiskAudioFile(audioFile, tempChar, 1);

SDK_SaveToDiskAudioFile :
[0] Error :
PROC:SaveToDiskAudioFile
ERROR:Access violation at address 000000000136CDDE in module 'Usine.exe'. Read of address
0000000000001190

if anyone has a working example using sdkSaveToDiskAudioFile, could you please show it to me !

thanx

Olivar
http://oli-lab.org

Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces

follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social

Post Reply

Who is online

Users browsing this forum: No registered users and 57 guests