comparison 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
comparison
equal deleted inserted replaced
524:7ef5c73ea8fa 525:fa7676dbf6f2
728 728
729 if (soundReverse && !noSpecialEffects) 729 if (soundReverse && !noSpecialEffects)
730 { 730 {
731 soundFinalWave[++soundBufferIndex] = res; 731 soundFinalWave[++soundBufferIndex] = res;
732 if ((soundFrameSoundWritten + 1) >= countof(soundFrameSound)) 732 if ((soundFrameSoundWritten + 1) >= countof(soundFrameSound))
733 printf("oh noes!\n"); 733
734 ; //printf("oh noes!\n");
734 else 735 else
735 soundFrameSound[++soundFrameSoundWritten] = res; 736 soundFrameSound[++soundFrameSoundWritten] = res;
736 } 737 }
737 else 738 else
738 { 739 {
739 soundFinalWave[soundBufferIndex++] = res; 740 soundFinalWave[soundBufferIndex++] = res;
740 if (soundFrameSoundWritten >= countof(soundFrameSound)) 741 if (soundFrameSoundWritten >= countof(soundFrameSound))
741 printf("oh noes!\n"); 742 ; //printf("oh noes!\n");
742 else 743 else
743 soundFrameSound[soundFrameSoundWritten++] = res; 744 soundFrameSound[soundFrameSoundWritten++] = res;
744 } 745 }
745 746
746 res = 0; 747 res = 0;
815 816
816 if (soundReverse && !noSpecialEffects) 817 if (soundReverse && !noSpecialEffects)
817 { 818 {
818 soundFinalWave[-1 + soundBufferIndex++] = res; 819 soundFinalWave[-1 + soundBufferIndex++] = res;
819 if ((soundFrameSoundWritten) >= countof(soundFrameSound)) 820 if ((soundFrameSoundWritten) >= countof(soundFrameSound))
820 printf("oh noes!\n"); 821 ;//printf("oh noes!\n");
821 else 822 else
822 soundFrameSound[-1 + soundFrameSoundWritten++] = res; 823 soundFrameSound[-1 + soundFrameSoundWritten++] = res;
823 } 824 }
824 else 825 else
825 { 826 {
826 soundFinalWave[soundBufferIndex++] = res; 827 soundFinalWave[soundBufferIndex++] = res;
827 if ((soundFrameSoundWritten + 1) >= countof(soundFrameSound)) 828 if ((soundFrameSoundWritten + 1) >= countof(soundFrameSound))
828 printf("oh noes!\n"); 829 ;//printf("oh noes!\n");
829 else 830 else
830 soundFrameSound[soundFrameSoundWritten++] = res; 831 soundFrameSound[soundFrameSoundWritten++] = res;
831 } 832 }
832 } 833 }
833 834
834 void gbSoundTick() 835 void gbSoundTick()
835 { 836 {
836 if (systemSoundOn) 837 if (systemSoundOn)
837 { 838 {
838 if (soundMasterOn) 839 if (soundMasterOn)
839 { 840 {
840 gbSoundChannel1(); 841 gbSoundChannel1();
841 gbSoundChannel2(); 842 gbSoundChannel2();
842 gbSoundChannel3(); 843 gbSoundChannel3();
843 gbSoundChannel4(); 844 gbSoundChannel4();
844 845
845 gbSoundMix(); 846 gbSoundMix();
846 } 847 }
847 else 848 else
848 { 849 {
849 soundFinalWave[soundBufferIndex++] = 0; 850 soundFinalWave[soundBufferIndex++] = 0;
850 soundFinalWave[soundBufferIndex++] = 0; 851 soundFinalWave[soundBufferIndex++] = 0;
851 if ((soundFrameSoundWritten + 1) >= countof(soundFrameSound)) 852 if ((soundFrameSoundWritten + 1) >= countof(soundFrameSound))
852 853
853 printf("oh noes!\n"); 854 ;//printf("oh noes!\n");
854 else 855 else
855 { 856 {
856 soundFrameSound[soundFrameSoundWritten++] = 0; 857 soundFrameSound[soundFrameSoundWritten++] = 0;
857 soundFrameSound[soundFrameSoundWritten++] = 0; 858 soundFrameSound[soundFrameSoundWritten++] = 0;
858 } 859 }
859 } 860 }
860 861
861 soundIndex++; 862 soundIndex++;
862 863
863 if (2 * soundBufferIndex >= soundBufferLen) 864 if (2 * soundBufferIndex >= soundBufferLen)
864 { 865 {
865 if (systemSoundOn) 866 if (systemSoundOn)
866 { 867 {
867 if (soundPaused) 868 if (soundPaused)
868 { 869 {
869 extern void soundResume(); 870 extern void soundResume();
870 soundResume(); 871 soundResume();
871 } 872 }
872 873
873 systemSoundWriteToBuffer(); 874 systemSoundWriteToBuffer();
874 } 875 }
875 soundIndex = 0; 876 soundIndex = 0;
876 soundBufferIndex = 0; 877 soundBufferIndex = 0;
877 } 878 }
878 } 879 }
879 } 880 }
880 881
881 void gbSoundReset() 882 void gbSoundReset()
882 { 883 {
883 soundPaused = 1; 884 soundPaused = 1;