Torsar2

Need with help SampleGrabber
make snaps of sound.
Graph was built.
hr=SampleGrabber4Audio->GetConnectedMediaType(&mt);

wf->wFormatTag==1;

wf->nChannels==2;
wf->nSamplesPerSec=44100;
wf->nAvgBytesPerSec==176400;
wf->wBitsPerSample==16;
wf->nBlockAlign==4;

hr = SampleGrabber4Audio->GetCurrentBuffer(&cbBuffer, NULL);
For same videofile return different size of buffer 13824 or 9216.
Such size of the buffer whence undertakes
I think need retun wf->wBitsPerSample/8==2 bytes


Re: DirectShow Development sound and samples(SampleGrabber,DShow)

Michel Roujansky

For PCM/Wave audio, one IMediaSample (=one capture buffer) contains lots of audio samples concatenated. In your case, 9216 bytes = 2304 * 2 channels * 2 bytes_per_sample.




Re: DirectShow Development sound and samples(SampleGrabber,DShow)

Torsar2

How to receive the certain amount samples
Admit I want to receive 1 sample
BYTE *Buffer=new BYTE [cbBuffer];
hr = SampleGrabber4Audio- > GetCurrentBuffer ((long *) *cbBuffer ,( long *) Buffer);
BYTE *onesample=new BYTE[ChennalsCount*BytesPerSample];
memcpy (Buffer, onesample, ChennalsCount*BytesPerSample);


Or 1000 samples
BYTE *onesample=new BYTE[ChennalsCount*BytesPerSample*100];
memcpy (Buffer, onesample, ChennalsCount*BytesPerSample*100);
I correctly think




Re: DirectShow Development sound and samples(SampleGrabber,DShow)

Michel Roujansky

yes, as long as you copy less than cbBuffer...




Re: DirectShow Development sound and samples(SampleGrabber,DShow)

Torsar2

if I am set position of graph in 0 sample
and get buffer(for example 3456 byte),
then set position in 10 sample
(to 3456 byte)
in second case bufer begin from 10 sample and it length 3456 byte
set of 1 and second buffers to are crossed