diff src/gb/gbSound.cpp @ 525:fa7676dbf6f2

sound recording test now works.
author Robert McIntyre <rlm@mit.edu>
date Sun, 24 Jun 2012 13:12:51 -0500
parents 7ef5c73ea8fa
children
line wrap: on
line diff
     1.1 --- a/src/gb/gbSound.cpp	Sat Jun 23 23:10:31 2012 -0500
     1.2 +++ b/src/gb/gbSound.cpp	Sun Jun 24 13:12:51 2012 -0500
     1.3 @@ -730,7 +730,8 @@
     1.4  	{
     1.5  		soundFinalWave[++soundBufferIndex] = res;
     1.6  		if ((soundFrameSoundWritten + 1) >= countof(soundFrameSound))
     1.7 -		  printf("oh noes!\n");
     1.8 +		  
     1.9 +		  ; //printf("oh noes!\n");
    1.10  		else
    1.11  			soundFrameSound[++soundFrameSoundWritten] = res;
    1.12  	}
    1.13 @@ -738,7 +739,7 @@
    1.14  	{
    1.15  		soundFinalWave[soundBufferIndex++] = res;
    1.16  		if (soundFrameSoundWritten >= countof(soundFrameSound))
    1.17 -		  printf("oh noes!\n");
    1.18 +		  ; //printf("oh noes!\n");
    1.19  		else
    1.20  			soundFrameSound[soundFrameSoundWritten++] = res;
    1.21  	}
    1.22 @@ -817,7 +818,7 @@
    1.23  	{
    1.24  		soundFinalWave[-1 + soundBufferIndex++]		   = res;
    1.25  		if ((soundFrameSoundWritten) >= countof(soundFrameSound))
    1.26 -		  printf("oh noes!\n");
    1.27 +		  ;//printf("oh noes!\n");
    1.28  		else
    1.29  			soundFrameSound[-1 + soundFrameSoundWritten++] = res;
    1.30  	}
    1.31 @@ -825,7 +826,7 @@
    1.32  	{
    1.33  		soundFinalWave[soundBufferIndex++]			  = res;
    1.34  		if ((soundFrameSoundWritten + 1) >= countof(soundFrameSound))
    1.35 -		  printf("oh noes!\n");
    1.36 +		  ;//printf("oh noes!\n");
    1.37  		else
    1.38  			soundFrameSound[soundFrameSoundWritten++] = res;
    1.39  	}
    1.40 @@ -833,49 +834,49 @@
    1.41  
    1.42  void gbSoundTick()
    1.43  {
    1.44 -	if (systemSoundOn)
    1.45 +  if (systemSoundOn)
    1.46 +    {
    1.47 +      if (soundMasterOn)
    1.48  	{
    1.49 -		if (soundMasterOn)
    1.50 +	  gbSoundChannel1();
    1.51 +	  gbSoundChannel2();
    1.52 +	  gbSoundChannel3();
    1.53 +	  gbSoundChannel4();
    1.54 +
    1.55 +	  gbSoundMix();
    1.56 +	}
    1.57 +      else
    1.58 +	{
    1.59 +	  soundFinalWave[soundBufferIndex++] = 0;
    1.60 +	  soundFinalWave[soundBufferIndex++] = 0;
    1.61 +	  if ((soundFrameSoundWritten + 1) >= countof(soundFrameSound))
    1.62 +			  
    1.63 +	    ;//printf("oh noes!\n");
    1.64 +	  else
    1.65 +	    {
    1.66 +	      soundFrameSound[soundFrameSoundWritten++] = 0;
    1.67 +	      soundFrameSound[soundFrameSoundWritten++] = 0;
    1.68 +	    }
    1.69 +	}
    1.70 +
    1.71 +      soundIndex++;
    1.72 +
    1.73 +      if (2 * soundBufferIndex >= soundBufferLen)
    1.74 +	{
    1.75 +	  if (systemSoundOn)
    1.76 +	    {
    1.77 +	      if (soundPaused)
    1.78  		{
    1.79 -			gbSoundChannel1();
    1.80 -			gbSoundChannel2();
    1.81 -			gbSoundChannel3();
    1.82 -			gbSoundChannel4();
    1.83 -
    1.84 -			gbSoundMix();
    1.85 -		}
    1.86 -		else
    1.87 -		{
    1.88 -			soundFinalWave[soundBufferIndex++] = 0;
    1.89 -			soundFinalWave[soundBufferIndex++] = 0;
    1.90 -			if ((soundFrameSoundWritten + 1) >= countof(soundFrameSound))
    1.91 -			  
    1.92 -			printf("oh noes!\n");
    1.93 -			else
    1.94 -			{
    1.95 -				soundFrameSound[soundFrameSoundWritten++] = 0;
    1.96 -				soundFrameSound[soundFrameSoundWritten++] = 0;
    1.97 -			}
    1.98 +		  extern void soundResume();
    1.99 +		  soundResume();
   1.100  		}
   1.101  
   1.102 -		soundIndex++;
   1.103 -
   1.104 -		if (2 * soundBufferIndex >= soundBufferLen)
   1.105 -		{
   1.106 -			if (systemSoundOn)
   1.107 -			{
   1.108 -				if (soundPaused)
   1.109 -				{
   1.110 -					extern void soundResume();
   1.111 -					soundResume();
   1.112 -				}
   1.113 -
   1.114 -				systemSoundWriteToBuffer();
   1.115 -			}
   1.116 -			soundIndex		 = 0;
   1.117 -			soundBufferIndex = 0;
   1.118 -		}
   1.119 +	      systemSoundWriteToBuffer();
   1.120 +	    }
   1.121 +	  soundIndex		 = 0;
   1.122 +	  soundBufferIndex = 0;
   1.123  	}
   1.124 +    }
   1.125  }
   1.126  
   1.127  void gbSoundReset()