How to Convert Mp3 into Pcm Using Audioconverterfillcomplexbuffer in Audiofilestreamopen's Audiofilestream_Packetsproc Callback

Unable to convert mp3 into PCM using AudioConverterFillComplexBuffer in AudioFileStreamOpen's AudioFileStream_PacketsProc callback

Hej @3254523, I have some answers with possible solutions for you. I hope to guide you in the right way in spite of I am not expert in this major. So, the problem is for sure the configuration of:

AudioBufferList

Here the links that probes the hints of this -50 OSStatus related to the AudioBufferList:
http://lists.apple.com/archives/coreaudio-api/2012/Apr/msg00041.html
https://forums.developer.apple.com/thread/6313

Now, we have to focus in a solutions. Looking through your AudioBufferList, you have no assigned any value but mNumberBuffers which is 1. Try to change the values in the following way(as it shown in the second link):

var localPcmBufferList = AudioBufferList(mNumberBuffers: 2, mBuffers: AudioBuffer(mNumberChannels: 2, mDataByteSize: UInt32(buffer.count), mData: &buffer))

If still is not working, we have to focus to correct it properly, hence here you can find the solution to the -50 OSStatus in AudioConverterFillComplexBuffer although not in swift:

AudioConverterFillComplexBuffer return -50 (paramErr)

iPhone: AudioBufferList init and release

AudioConverterFillComplexBuffer return -50 (paramErr)

I was stuck in the same situation (basically after using your code as a template). Solution seems to be in allocation of memory for the AudioBufferList. Implementing this answer did the trick for me (although my objective-C is not good enough to see the exact difference :))

iPhone: AudioBufferList init and release

Here is how I do it:

AudioBufferList *
AllocateABL(UInt32 channelsPerFrame, UInt32 bytesPerFrame, bool interleaved, UInt32 capacityFrames)
{
AudioBufferList *bufferList = NULL;

UInt32 numBuffers = interleaved ? 1 : channelsPerFrame;
UInt32 channelsPerBuffer = interleaved ? channelsPerFrame : 1;

bufferList = static_cast<AudioBufferList *>(calloc(1, offsetof(AudioBufferList, mBuffers) + (sizeof(AudioBuffer) * numBuffers)));

bufferList->mNumberBuffers = numBuffers;

for(UInt32 bufferIndex = 0; bufferIndex < bufferList->mNumberBuffers; ++bufferIndex) {
bufferList->mBuffers[bufferIndex].mData = static_cast<void *>(calloc(capacityFrames, bytesPerFrame));
bufferList->mBuffers[bufferIndex].mDataByteSize = capacityFrames * bytesPerFrame;
bufferList->mBuffers[bufferIndex].mNumberChannels = channelsPerBuffer;
}

return bufferList;
}

What's the best way to compare two sheets in an Excel workbook

In Excel VBA, use a Dictionary. Use your items from one of the sheets as keys, QTY as values. Put the item/QTY pairs of sheet 1 into the dictionary, then run through the items of sheet 2 update the dictionary accordingly to get the differences in there. Finally, put the result into sheet 3.

EDIT: here is a complete example in code (you have to set a reference to the Microsoft Scripting runtime to get it working this way):

Option Explicit
Sub CreateDiff()

Dim dict As New Dictionary
Dim sh1 As Worksheet, sh2 As Worksheet, sh3 As Worksheet
Dim i As Long, v As String

Set sh1 = ThisWorkbook.Sheets("Sheet1")
Set sh2 = ThisWorkbook.Sheets("Sheet2")
Set sh3 = ThisWorkbook.Sheets("Sheet3")
For i = 2 To sh1.Cells.SpecialCells(xlCellTypeLastCell).Row
v = Trim(sh1.Cells(i, 1).Value)
dict(v) = -sh1.Cells(i, 2).Value
Next
For i = 2 To sh2.Cells.SpecialCells(xlCellTypeLastCell).Row
v = Trim(sh2.Cells(i, 1).Value)
If dict.Exists(v) Then
dict(v) = dict(v) + sh2.Cells(i, 2).Value
Else
dict(v) = sh2.Cells(i, 2).Value
End If
Next
For i = 0 To dict.Count - 1
v = dict.Keys(i)
sh3.Cells(i + 2, 1) = v
sh3.Cells(i + 2, 2) = dict(v)
Next

End Sub


Related Topics



Leave a reply



Submit