freeMXF.orghttp://freemxf.org/forum/ freeMXF Binaries Problemhttp://freemxf.org/forum/viewtopic.php?f=2&t=187 Page 2 of 2

 Author: m0nKeY [ Wed Jan 06, 2010 4:48 pm ] Post subject: I got some questions about your pseudocode: Code:WriteWaveHeader()For each sample of input data{Waht do you mean here? One Sample for all 8 channels or one sample for each channel?Code:    For channel is 1 .. 8    {Do you mean that i have to count up from channel 1 to channel 8 in a for-loop? For examplefor(i = 0; i >= channel - 1; i++);Code:        Read 4 bytes from the source data        If channel is less than or equal to number of channels        {            If data is 16 bits                build a 16-bit word from source byte 2, top 4 bits,                    followed by byte 3 bottom 4 bits, then byte 3 top 4 bits,                    then byte 4 bottom 4 bits                       If data is 24 bits                build a 24-bit word from source byte 1, top 4 bits,                    followed by byte 2 bottom 4 bits, then byte 2, top 4 bits,                    then byte 3 bottom 4 bits, then byte 3 top 4 bits,                    then byte 4 bottom 4 bits            Write the new value to the output file        }    } I dont understand why i made a for-loop bevor and now a if-clause? Do i have to read the three first bits wich identifies the channel in each sample? Greetings Sebastian

 Author: Matt Beard [ Thu Jan 07, 2010 11:00 am ] Post subject: m0nKeY wrote:Waht do you mean here? One Sample for all 8 channels or one sample for each channel?One sample in this case means for all channels, so for example if you have 48kHz audio with 4 channels, you will have 48000 samples per second, each will contain 4 audio values (one per channel) and 4 dummy values that will need to be discarded (because the wrapping is always 8 channel, no matter how many channels are used).m0nKeY wrote:Do you mean that i have to count up from channel 1 to channel 8 in a for-loop? For examplefor(i = 0; i >= channel - 1; i++);Yes (sort of), but I would rather do:for(int chan = 1; chan <= 8; chan++){ // Code here}m0nKeY wrote:I dont understand why i made a for-loop bevor and now a if-clause? Do i have to read the three first bits wich identifies the channel in each sample?The outer loop executes for each set of audio samples (8 values per sample). The inner loop executes for each of the 8 values in the sample. Each of these values is either 16 or 24 bits and what you do with the data depends on that (the file will be all 16-bit or all 24-bit). There is no need to read the channel number from the sampe data because the loop variable of the inner loop will give you that. The header metadata will tell you whether the file is 16-bit or 24-bit and how many channels are active.

 Author: m0nKeY [ Thu Jan 07, 2010 4:45 pm ] Post subject: Thanks, now i understand what you mean. And i know you worked not alone on the standard. I think no one could do such a standard all alone. And you didn't not write the hole "the mxf book", but a chapter. There is still one question about the structure of the audiostream. Let me do some calculation for example. A one frame long stream has 48kHz / 25 = 1920 samples. Each sample has 8 channels, so there are 1920 samples * 8 channels = 15360 datawords. One dataword is 4 bytes or 32 bits long, including the 24 - 16 bit PCM sample. So the total streamsize should be 61440 bytes. But the audiostream from my one frame long mxf file has a size of 61444 bytes. I dont know why there is a difference of 4 bytes? And here is the code i wrote. Code:for(int i = 0; i < in.length()/32; i++) //streamsize in byte * 8 bit / 8 channels / 32 bits per word      {         for(int j = 1; j <= 8; j++)         {                        instream.read(data, 0, 4);            if (j <= NumChannels)            {               short word = Create16BitPCMSample(data);               outstream.write(ShortToByteArray(word));            }         }      }Code: private static short Create16BitPCMSample (byte[] data)   {      int buffer  = ((0xF0 & data) << 8) | ((0x0F & data) << 8) | (0xF0 & data) | (0x0F & data);      short word = IntToShort(buffer);            return word;   } Greetings Sebastian

 Author: Matt Beard [ Fri Jan 08, 2010 9:51 am ] Post subject: Ah, yes! You are right - there is a 4-byte header on each frame that can be skipped.

 Author: m0nKeY [ Fri Jan 08, 2010 11:02 am ] Post subject: Hi, because of my bad englisch i have to ask again. With frame you mean videoframe, so every 1920 audiosamples? Greetings Sebastian

 Author: Matt Beard [ Tue Jan 12, 2010 11:24 am ] Post subject: Yes, every video frame, or I should have said each content package to be exact.