Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
Hello, I am trying to use irrklang to join two wav files, but I am kind of stuck right now. For the beginning I would like to just simply attach the data segment of one wav file to itself *to practice*. For example: the input wav file might be 3 seconds long and someone says "ok", -> I want the output wavfile to be six second long with the person saying ok, twice - i hope this makes sense^^ I doubled the length and size, but something seems to be wrong with the way i duplicate the data buffer...
|
||||
|
sorry about this post I figured it out myself. The second counter obviously has to check against dataLen * 2
|
||||
|
Nice :) |
||||
|
thx :) on a similar note, I have change the method now so it can now eiterh join two wav files, or join two wave files with a user-specified intervall in the middle - however... there are sound artifacts at the end of my first wav / at the beginning of the intervall wav. Apparently this is quite normal and the way around it would be to fade out at the end of wav 1 and fade back in at the beginning of wav 2. / the dummy intervall wav. Also see: http://www.ambiera.com/forum.php?t=307 The only problem now is that my wav files are already recorded so I basically need to change the volume in the data segment in the recorded wav file... is there any way to access this data with irrklang ? and then change the volume of say the last 0.5 seconds ? |
||||
|
SelbstgesprÃĪche... In case someone needs it in the future - the trick with the audio artifacts was to use memset on the allocated buffers before filling them with other stuff . This part of the function below should get anyone on the right track that wants to add a buffer-wav of x-length to their preexisting wav. Great API ! by the way // that here is the formular to compute the length of the data segment in the buffer wav unsigned long dataLen2 = format1.SampleRate * format1.ChannelCount * format1.getSampleSize() * seconds; char* emptybuf = new char[dataLen2]; // lets create a bigbuffer, so we can attach the seconddatabuffer to the first. char* bigbuffer = new char[dataLen1+dataLen2]; //sizeof(emptybuf)]; // prevents audio artifacts !! - very important memset(bigbuffer,0,dataLen1+dataLen2); memset(emptybuf,0,dataLen2); char* firstbuffer = (char*)data1; char* secondbuffer = emptybuf; int counter1=0; int counter2 =0; while(counter1 < dataLen1 ) { bigbuffer[counter1] = firstbuffer[counter1]; // * x increases volume counter1++; } while(counter1 < dataLen1+dataLen2) { bigbuffer[counter1] = secondbuffer[counter2]; counter1++; counter2++; } dataLen2 = dataLen1+dataLen2; totalLen1 = waveHeaderLen1 + dataLen2; |
|