| 
									
										
										
										
											2022-03-04 18:18:43 -05:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Furnace Tracker - multi-system chiptune tracker | 
					
						
							| 
									
										
										
										
											2023-01-19 19:18:40 -05:00
										 |  |  |  * Copyright (C) 2021-2023 tildearrow and contributors | 
					
						
							| 
									
										
										
										
											2022-03-04 18:18:43 -05:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or modify | 
					
						
							|  |  |  |  * it under the terms of the GNU General Public License as published by | 
					
						
							|  |  |  |  * the Free Software Foundation; either version 2 of the License, or | 
					
						
							|  |  |  |  * (at your option) any later version. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU General Public License along | 
					
						
							|  |  |  |  * with this program; if not, write to the Free Software Foundation, Inc., | 
					
						
							|  |  |  |  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef _PCSPKR_H
 | 
					
						
							|  |  |  | #define _PCSPKR_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "../dispatch.h"
 | 
					
						
							| 
									
										
										
										
											2023-07-13 05:09:20 -04:00
										 |  |  | #include "../fixedQueue.h"
 | 
					
						
							| 
									
										
										
										
											2022-06-02 03:59:07 -04:00
										 |  |  | #include <thread>
 | 
					
						
							|  |  |  | #include <mutex>
 | 
					
						
							|  |  |  | #include <condition_variable>
 | 
					
						
							| 
									
										
										
										
											2022-03-04 18:18:43 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | class DivPlatformPCSpeaker: public DivDispatch { | 
					
						
							| 
									
										
										
										
											2022-12-13 02:22:48 -05:00
										 |  |  |   struct Channel: public SharedChannel<signed char> { | 
					
						
							| 
									
										
										
										
											2022-03-04 18:18:43 -05:00
										 |  |  |     Channel(): | 
					
						
							| 
									
										
										
										
											2022-12-13 02:22:48 -05:00
										 |  |  |       SharedChannel<signed char>(15) {} | 
					
						
							| 
									
										
										
										
											2022-03-04 18:18:43 -05:00
										 |  |  |   }; | 
					
						
							|  |  |  |   Channel chan[1]; | 
					
						
							| 
									
										
										
											
												per-channel oscilloscope, part 5
SAA1099 (SAASound and MAME), Lynx, MMC5, N163, PC Engine, PC Speaker,
PET, QSound, WonderSwan, VERA, VIC-20, VRC6 and X1-010!
											
										 
											2022-05-01 03:40:03 -04:00
										 |  |  |   DivDispatchOscBuffer* oscBuf; | 
					
						
							| 
									
										
										
										
											2022-06-02 03:59:07 -04:00
										 |  |  |   std::thread* realOutThread; | 
					
						
							|  |  |  |   std::mutex realOutSelfLock; | 
					
						
							|  |  |  |   std::condition_variable realOutCond; | 
					
						
							|  |  |  |   bool realOutQuit; | 
					
						
							|  |  |  |   struct RealQueueVal { | 
					
						
							| 
									
										
										
										
											2022-06-03 00:27:28 -04:00
										 |  |  |     int tv_sec, tv_nsec; | 
					
						
							| 
									
										
										
										
											2022-06-02 03:59:07 -04:00
										 |  |  |     unsigned short val; | 
					
						
							| 
									
										
										
										
											2023-07-13 05:09:20 -04:00
										 |  |  |     RealQueueVal(): | 
					
						
							|  |  |  |       tv_sec(0), | 
					
						
							|  |  |  |       tv_nsec(0), | 
					
						
							|  |  |  |       val(0) {} | 
					
						
							| 
									
										
										
										
											2022-06-03 00:27:28 -04:00
										 |  |  |     RealQueueVal(int sec, int nsec, unsigned short v): | 
					
						
							|  |  |  |       tv_sec(sec), | 
					
						
							|  |  |  |       tv_nsec(nsec), | 
					
						
							| 
									
										
										
										
											2022-06-02 03:59:07 -04:00
										 |  |  |       val(v) {} | 
					
						
							|  |  |  |   }; | 
					
						
							| 
									
										
										
										
											2023-07-13 05:09:20 -04:00
										 |  |  |   FixedQueue<RealQueueVal,2048> realQueue; | 
					
						
							| 
									
										
										
										
											2022-06-02 03:59:07 -04:00
										 |  |  |   std::mutex realQueueLock; | 
					
						
							| 
									
										
										
										
											2022-03-04 18:18:43 -05:00
										 |  |  |   bool isMuted[1]; | 
					
						
							| 
									
										
										
										
											2022-06-03 02:18:32 -04:00
										 |  |  |   bool on, flip, lastOn, realOutEnabled; | 
					
						
							|  |  |  |   int pos, speakerType, beepFD, realOutMethod; | 
					
						
							| 
									
										
										
										
											2022-03-05 00:36:50 -05:00
										 |  |  |   float low, band; | 
					
						
							|  |  |  |   float low2, high2, band2; | 
					
						
							|  |  |  |   float low3, band3; | 
					
						
							| 
									
										
										
										
											2022-03-05 15:00:19 -05:00
										 |  |  |   unsigned short freq, lastFreq; | 
					
						
							| 
									
										
										
										
											2022-03-04 18:18:43 -05:00
										 |  |  |   unsigned char regPool[2]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-23 10:24:02 -04:00
										 |  |  |   friend void putDispatchChip(void*,int); | 
					
						
							| 
									
										
										
										
											2022-03-04 18:18:43 -05:00
										 |  |  |   friend void putDispatchChan(void*,int,int); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-02 03:59:07 -04:00
										 |  |  |   void beepFreq(int freq, int delay=0); | 
					
						
							| 
									
										
										
										
											2022-03-06 03:33:56 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-03 01:09:46 -05:00
										 |  |  |   void acquire_unfilt(short** buf, size_t len); | 
					
						
							|  |  |  |   void acquire_cone(short** buf, size_t len); | 
					
						
							|  |  |  |   void acquire_piezo(short** buf, size_t len); | 
					
						
							|  |  |  |   void acquire_real(short** buf, size_t len); | 
					
						
							| 
									
										
										
										
											2022-03-05 00:36:50 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-04 18:18:43 -05:00
										 |  |  |   public: | 
					
						
							| 
									
										
										
										
											2022-06-02 03:59:07 -04:00
										 |  |  |     void pcSpeakerThread(); | 
					
						
							| 
									
										
										
										
											2023-01-02 04:53:37 -05:00
										 |  |  |     void acquire(short** buf, size_t len); | 
					
						
							| 
									
										
										
										
											2022-03-04 18:18:43 -05:00
										 |  |  |     int dispatch(DivCommand c); | 
					
						
							|  |  |  |     void* getChanState(int chan); | 
					
						
							| 
									
										
										
										
											2022-06-05 19:17:00 -04:00
										 |  |  |     DivMacroInt* getChanMacroInt(int ch); | 
					
						
							| 
									
										
										
											
												per-channel oscilloscope, part 5
SAA1099 (SAASound and MAME), Lynx, MMC5, N163, PC Engine, PC Speaker,
PET, QSound, WonderSwan, VERA, VIC-20, VRC6 and X1-010!
											
										 
											2022-05-01 03:40:03 -04:00
										 |  |  |     DivDispatchOscBuffer* getOscBuffer(int chan); | 
					
						
							| 
									
										
										
										
											2022-03-04 18:18:43 -05:00
										 |  |  |     unsigned char* getRegisterPool(); | 
					
						
							|  |  |  |     int getRegisterPoolSize(); | 
					
						
							|  |  |  |     void reset(); | 
					
						
							|  |  |  |     void forceIns(); | 
					
						
							| 
									
										
										
										
											2022-04-15 16:01:11 -04:00
										 |  |  |     void tick(bool sysTick=true); | 
					
						
							| 
									
										
										
										
											2022-03-04 18:18:43 -05:00
										 |  |  |     void muteChannel(int ch, bool mute); | 
					
						
							|  |  |  |     bool keyOffAffectsArp(int ch); | 
					
						
							| 
									
										
										
										
											2022-09-29 21:13:40 -04:00
										 |  |  |     void setFlags(const DivConfig& flags); | 
					
						
							| 
									
										
										
										
											2022-03-04 18:18:43 -05:00
										 |  |  |     void notifyInsDeletion(void* ins); | 
					
						
							| 
									
										
										
										
											2022-03-07 01:48:48 -05:00
										 |  |  |     void notifyPlaybackStop(); | 
					
						
							| 
									
										
										
										
											2022-03-04 18:18:43 -05:00
										 |  |  |     void poke(unsigned int addr, unsigned short val); | 
					
						
							|  |  |  |     void poke(std::vector<DivRegWrite>& wlist); | 
					
						
							|  |  |  |     const char** getRegisterSheet(); | 
					
						
							| 
									
										
										
										
											2022-09-29 21:13:40 -04:00
										 |  |  |     int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags); | 
					
						
							| 
									
										
										
										
											2022-03-04 18:18:43 -05:00
										 |  |  |     void quit(); | 
					
						
							|  |  |  |     ~DivPlatformPCSpeaker(); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif
 |