19 Jun '13 - 01:48 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Reply  |  Print  
Author Topic: mixing to audio files. What addon do i use  (Read 481 times)
jakob
Posts: 70


« on: 3 Aug '12 - 11:14 »
Reply with quoteQuote

hi
I have two audio files. one of them needs to be inserted within the other at a specific position.
i thougth of doing it like this:
copy audio1 up till insertion point into an empty temp file.
append audio2 to temp file.
append rest of audio1 to temp file.

I can't figure out if BASS can du this kind of thing.
i tried to use BASS_StreamCreateFile, but this only works for the audio files not for creating the empty audio file.
How do i create an empty audio file in the right audio format.
Can anyone point me in the right direction?
Logged
Chris
Posts: 1507


« Reply #1 on: 3 Aug '12 - 12:09 »
Reply with quoteQuote

Hi
Bass_Mix will do that for you

Chris
Logged
jakob
Posts: 70


« Reply #2 on: 3 Aug '12 - 15:07 »
Reply with quoteQuote

Hi Chris

thanks for the quick reply

I don't want to play the resulting stream i only want save the result in a new file. Isn't there a way to loop through data from a stream and write it to another file.
I looked at WaveWriter because i use that allready during recording so i know that that can write to another file but i'm needing a WaveReader.
As i understand the mixer, then it doesn't create a new file for me does it?
And also it seems that the mixer takes multiple streams but not part of a stream.
i need to read part of a stream and put it in a new file and then read part of another stream and append that to new file aswell.
this is what i have tried so fare with only one audio file beeing copied to new one, but with no luck (it can play the resulting file but it's only noise):

creating the streams and the resulting WaveWriter:

Bass.BASS_Init(DeviceNumber, 44100, BASSInit.BASS_DEVICE_NOSPEAKER | BASSInit.BASS_DEVICE_MONO, WindowHandle);
int AudioStream = Bass.BASS_StreamCreateFile(CurrentAudioRecordingFile, 0, 0, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_PRESCAN);
WaveWriter tempStreamWriter = new WaveWriter(temporaryOut, 1, 44100, 16, true);

write data to resulting WaveWriter:

            int dataRead = 0;
            while (dataRead < copyDataLength)
            {
                int readSize = InitParams.CopyBufferSize;
                if (readSize > (copyDataLength - dataRead))
                {
                    readSize = copyDataLength - dataRead;
                }


                byte[] data = new byte[readSize];
                long actualReadSize = Bass.BASS_ChannelGetData(AudioStream , data, readSize);
               
                if (actualReadSize != readSize)
                {
                    log.Warn("could not read enough data in WriteWaveSegment");
                }
                outStreamWriter.Write(data, (int)actualReadSize);
                dataRead += readSize;
            }
Logged
Ian @ un4seen
Administrator
Posts: 15363


« Reply #3 on: 3 Aug '12 - 17:11 »
Reply with quoteQuote

To process part of a file, you would use BASS_ChannelSetPosition to seek to the start position and then process the amount of data necessary to reach the end position. The BASSenc add-on can be used for the file writing. Writing parts from 2 files could be done something like this...

BASS_Encode_Start(source1, "output.wav" BASS_ENCODE_PCM, 0, 0); // set an encoder (WAV writer) on the 1st source
BASS_ChanneSetPosition(source1, startpos1, BASS_POS_BYTE); // seek to the start position
QWORD todo=endpos1-startpos1; // the amount of data to process
while (todo && BASS_ChannelIsActive(source1)) {
BYTE buf[20000]; // processing buffer
DWORD c=BASS_ChannelGetData(source1, buf, min(todo, sizeof(buf)); // process some data
todo-=c; // count down
}
BASS_Encode_SetChannel(source1, source2); // move the encoder to the 2nd source
BASS_ChanneSetPosition(source2, startpos2, BASS_POS_BYTE); // seek to the start position
todo=endpos2-startpos2; // the amount of data to process
while (todo && BASS_ChannelIsActive(source2)) {
BYTE buf[20000]; // processing buffer
DWORD c=BASS_ChannelGetData(source2, buf, min(todo, sizeof(buf)); // process some data
todo-=c; // count down
}
BASS_Encode_Stop(source2); // close the encoder

Please see the documentation for details on the aforementioned functions.
Logged
jakob
Posts: 70


« Reply #4 on: 7 Aug '12 - 08:46 »
Reply with quoteQuote

hi Ian

thanks for the info, it seems to work Cheesy
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines