| Changed to this:
#include
#include
int main(void)
{
LPDIRECTSOUND ds;
DSBUFFERDESC bd;
WAVEFORMATEX wf;
LPDIRECTSOUNDBUFFER bf;
DirectSoundCreate(NULL, &ds, NULL);
IDirectSound_SetCooperativeLevel(ds, GetDesktopWindow(), DSSCL_PRIORITY);
ZeroMemory(&wf, sizeof(WAVEFORMATEX));
wf.wFormatTag = WAVE_FORMAT_PCM;
wf.wBitsPerSample = 16;
wf.nChannels = 1;
wf.nSamplesPerSec = 44100;
wf.nBlockAlign = wf.wBitsPerSample * wf.nChannels / 8;
wf.nAvgBytesPerSec = wf.nSamplesPerSec * wf.nBlockAlign;
ZeroMemory(&bd, sizeof(DSBUFFERDESC));
bd.dwSize = sizeof(DSBUFFERDESC);
bd.dwFlags = DSBCAPS_GLOBALFOCUS | DSBCAPS_LOCHARDWARE;
bd.dwBufferBytes = 44100*2*5;
bd.lpwfxFormat = &wf;
IDirectSound_CreateSoundBuffer(ds, &bd, &bf, NULL);
LPVOID ap1, ap2;
DWORD bt1, bt2;
IDirectSoundBuffer_Lock(bf, 0, 0, &ap1, &bt1, &ap2, &bt2,
DSBLOCK_ENTIREBUFFER);
int *q;
q = malloc(44100*5);
int t;
for (t = 0; t < 44100*5; t++)
*q++ = (t&t>>8);
CopyMemory(ap1, q, bt1);
IDirectSoundBuffer_Unlock(bf, ap1, bt1, ap2, bt2);
IDirectSoundBuffer_Play(bf, 0, 0, DSBPLAY_LOOPING);
Sleep(15000);
IDirectSoundBuffer_Stop(bf);
return 0;
}
Error reports vanish, but no sound. It's not even sleeping. :/
On 5/21/12, Adam Puckett wrote:
> Just tried changing the loop and getting the same thing.
>
> What I'm trying to do is fill the left channel of a 5-second buffer
> with silence and the right channel with an arbitrary bytebeat "song".
> I used (t&t>>8) as an example to see if I could get it to work.
>
> On 5/21/12, Sigurd Saue wrote:
>> I'm not 100 % sure what you want to achieve, but what if you change the
>> loop
>> counter to:
>>
>> for (t = 0; t < 44100*5; t++) // Removed *4
>>
>> Sigurd
>>
>> -----Original Message-----
>> From: Adam Puckett [mailto:adotsdothmusic@gmail.com]
>> Sent: Monday, May 21, 2012 4:11 PM
>> To: Developer discussions
>> Subject: Re: [Cs-dev] C bytebeat experiment
>>
>> What do I need to change?
>>
>> On 5/21/12, Sigurd Saue wrote:
>>> It looks to me like you're reading way beyond your buffer. You've
>>> allocated
>>> (44100*4*5) bytes, but in your loop you're accessing elements four
>>> times that size: q++ is a short pointer and moves two bytes for each
>>> increment and you do that twice for each step of the for loop.
>>>
>>> Sigurd
>>>
>>> -----Original Message-----
>>> From: Adam Puckett [mailto:adotsdothmusic@gmail.com]
>>> Sent: Monday, May 21, 2012 3:44 PM
>>> To: csound-devel@lists.sourceforge.net
>>> Subject: [Cs-dev] C bytebeat experiment
>>>
>>> The attached file compiles but the resulting exe crashes. What am I
>>> doing wrong? (OS: XP SP3, using DirectSound)
>>>
>>> Thanks.
>>>
>>> ----------------------------------------------------------------------
>>> --------
>>> Live Security Virtual Conference
>>> Exclusive live event will cover all the ways today's security and
>>> threat landscape has changed and how IT managers can respond.
>>> Discussions will include endpoint security, mobile security and the
>>> latest in malware threats.
>>> http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>
>>
>> ------------------------------------------------------------------------------
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and threat
>> landscape has changed and how IT managers can respond. Discussions will
>> include endpoint security, mobile security and the latest in malware
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>> ------------------------------------------------------------------------------
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and
>> threat landscape has changed and how IT managers can respond. Discussions
>> will include endpoint security, mobile security and the latest in malware
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net |