예제 #1
0
파일: karplus.cpp 프로젝트: kumaashi/dumped
//------------//------------//------------//------------//------------//------------
// ep
//------------//------------//------------//------------//------------//------------
int main(int argc, char *argv[])
{
  HANDLE h = SoundInit(FillFunc);
  printf("    Play : Z, X, C, V, B, N, M, K\nAutoPlay : Hold SpaceKey.\n");
  while(h && !(GetAsyncKeyState(VK_ESCAPE) & 0x8000)) {
    Sleep(0);
    static int root  = 0x6d;
    
    //AutoPlay
    if( GetAsyncKeyState(VK_SPACE) & 0x8000)
    {
      static unsigned long start = timeGetTime();
      unsigned long now = timeGetTime();
      static int count = 0;
      if( (now - start) > 6 )
      {
        //printf("%d\n", (now - start));
        start = now;
        static int count = 0;
        static int bass  = 1;
        count--;
        if(count < 0)
        {
          int table[] = { 10, 7, 3, 0, -7, -12, -24};
          for(int i = 0; i < 7; i++)
            if( (random() % 7) == 0) osc[i].On(root + table[i], i + 2);
          count = 16;
          bass++;
          if( (bass % 32) == 0)
          {
            root += (random() & 0x8) ? 4 : 0;
            root -= (random() & 0x8) ? 4 : 0;
          }
        }
      } else {
        Sleep(1);
      }
    }
    
    //kbd.
    if(GetAsyncKeyState('Z') & 0x0001) osc[0].On(root -24, 12);
    if(GetAsyncKeyState('X') & 0x0001) osc[1].On(root -12,  9);
    if(GetAsyncKeyState('C') & 0x0001) osc[2].On(root -5,   7);
    if(GetAsyncKeyState('V') & 0x0001) osc[3].On(root +0,   5);
    if(GetAsyncKeyState('B') & 0x0001) osc[4].On(root +3,   4);
    if(GetAsyncKeyState('N') & 0x0001) osc[5].On(root +7,   3);
    if(GetAsyncKeyState('M') & 0x0001) osc[6].On(root +10,  2);
    if(GetAsyncKeyState('K') & 0x0001) osc[7].On(root +12,  2);
  }
  SoundTerm(h);
  return 0;
}
예제 #2
0
파일: PspSound.c 프로젝트: wally4000/code
void SoundInit(void)
{
	if(soundInited)
		SoundTerm();

	if (!soundInited)		{
		if(snd.sample_rate)
		{
			//Wait the old thread to be deleted
			SoundWaitTerm();

			memset(audioOut, 0, 2*2048*sizeof(sample_t));

			soundRunning = 1;
			sndThid = sceKernelCreateThread("SoundThread", SoundThread, 0x11, 0xFA0, 0, 0); 

			if(sndThid<0)
				return;

			sceKernelStartThread(sndThid,0,0);  
			soundInited = 1;
		}
	}
}