/[pcsx2_0.9.7]/branch/debug/0.X/0.9.X/0.9.7/ramdump-lateset/plugins/spu2-x/src/Wavedump_wav.cpp
ViewVC logotype

Contents of /branch/debug/0.X/0.9.X/0.9.7/ramdump-lateset/plugins/spu2-x/src/Wavedump_wav.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 314 - (show annotations) (download)
Sun Dec 26 18:56:19 2010 UTC (9 years, 2 months ago) by william
File size: 3506 byte(s)
** merged upstream r4049 (re-integration of GregMiscellaneous branch)
** applied patched to GigTranser.cpp in ZZOgl from r4140 to change 'static int count = 0;' to 'static int path1_count = 0;')
1 /* SPU2-X, A plugin for Emulating the Sound Processing Unit of the Playstation 2
2 * Developed and maintained by the Pcsx2 Development Team.
3 *
4 * Original portions from SPU2ghz are (c) 2008 by David Quintana [gigaherz]
5 *
6 * SPU2-X is free software: you can redistribute it and/or modify it under the terms
7 * of the GNU Lesser General Public License as published by the Free Software Found-
8 * ation, either version 3 of the License, or (at your option) any later version.
9 *
10 * SPU2-X is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 * PURPOSE. See the GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with SPU2-X. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include "Global.h"
19 #ifdef __LINUX__
20 #include "WavFile.h"
21 #else
22 #include "soundtouch/WavFile.h"
23 #endif
24
25 static WavOutFile* _new_WavOutFile( const char* destfile )
26 {
27 return new WavOutFile( destfile, 48000, 16, 2 );
28 }
29
30 namespace WaveDump
31 {
32 static WavOutFile* m_CoreWav[2][CoreSrc_Count] = { NULL };
33
34 static const char* m_tbl_CoreOutputTypeNames[CoreSrc_Count] =
35 {
36 "Input",
37 "DryVoiceMix",
38 "WetVoiceMix",
39 "PreReverb",
40 "PostReverb",
41 "External"
42 };
43
44 void Open()
45 {
46 if( !IsDevBuild ) return;
47 if( !WaveLog() ) return;
48
49 char wavfilename[256];
50
51 for( uint cidx=0; cidx<2; cidx++ )
52 {
53 for( int srcidx=0; srcidx<CoreSrc_Count; srcidx++ )
54 {
55 safe_delete( m_CoreWav[cidx][srcidx] );
56 #ifdef __LINUX__
57 sprintf( wavfilename, "logs/spu2x-Core%d-%s.wav",
58 cidx, m_tbl_CoreOutputTypeNames[ srcidx ] );
59 #else
60 sprintf( wavfilename, "logs\\spu2x-Core%d-%s.wav",
61 cidx, m_tbl_CoreOutputTypeNames[ srcidx ] );
62 #endif
63
64 try
65 {
66 m_CoreWav[cidx][srcidx] = _new_WavOutFile( wavfilename );
67 }
68 catch( std::runtime_error& ex )
69 {
70 printf( "SPU2-X > %s.\n\tWave Log for this core source disabled.", ex.what() );
71 m_CoreWav[cidx][srcidx] = NULL;
72 }
73 }
74 }
75 }
76
77 void Close()
78 {
79 if( !IsDevBuild ) return;
80 for( uint cidx=0; cidx<2; cidx++ )
81 {
82 for( int srcidx=0; srcidx<CoreSrc_Count; srcidx++ )
83 {
84 safe_delete( m_CoreWav[cidx][srcidx] );
85 }
86 }
87 }
88
89 void WriteCore( uint coreidx, CoreSourceType src, const StereoOut16& sample )
90 {
91 if( !IsDevBuild ) return;
92 if( m_CoreWav[coreidx][src] != NULL )
93 m_CoreWav[coreidx][src]->write( (s16*)&sample, 2 );
94 }
95
96 void WriteCore( uint coreidx, CoreSourceType src, s16 left, s16 right )
97 {
98 WriteCore( coreidx, src, StereoOut16( left, right ) );
99 }
100 }
101
102 #include "Utilities/Threading.h"
103
104 using namespace Threading;
105
106 bool WavRecordEnabled = false;
107
108 static WavOutFile* m_wavrecord = NULL;
109 static Mutex WavRecordMutex;
110
111 void RecordStart()
112 {
113 WavRecordEnabled = false;
114
115 try
116 {
117 ScopedLock lock( WavRecordMutex );
118 safe_delete( m_wavrecord );
119 m_wavrecord = new WavOutFile( "recording.wav", 48000, 16, 2 );
120 WavRecordEnabled = true;
121 }
122 catch( std::runtime_error& )
123 {
124 m_wavrecord = NULL; // not needed, but what the heck. :)
125 SysMessage("SPU2-X couldn't open file for recording: %s.\nRecording to wavfile disabled.", "recording.wav");
126 }
127 }
128
129 void RecordStop()
130 {
131 WavRecordEnabled = false;
132 ScopedLock lock( WavRecordMutex );
133 safe_delete( m_wavrecord );
134 }
135
136 void RecordWrite( const StereoOut16& sample )
137 {
138 ScopedLock lock( WavRecordMutex );
139 if( m_wavrecord == NULL ) return;
140 m_wavrecord->write( (s16*)&sample, 2 );
141 }

  ViewVC Help
Powered by ViewVC 1.1.22