| 
									
										
										
										
											2019-10-08 14:33:38 -04:00
										 |  |  | #ifndef NOTIFICATIONAUDIO_H
 | 
					
						
							|  |  |  | #define NOTIFICATIONAUDIO_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <QIODevice>
 | 
					
						
							|  |  |  | #include <QBuffer>
 | 
					
						
							|  |  |  | #include <QAudioDeviceInfo>
 | 
					
						
							|  |  |  | #include <QAudioFormat>
 | 
					
						
							|  |  |  | #include <QAudioOutput>
 | 
					
						
							|  |  |  | #include <QFile>
 | 
					
						
							| 
									
										
										
										
											2019-11-26 14:23:39 -05:00
										 |  |  | #include <QPair>
 | 
					
						
							| 
									
										
										
										
											2019-10-15 13:52:30 -04:00
										 |  |  | #include <QPointer>
 | 
					
						
							| 
									
										
										
										
											2019-11-26 14:23:39 -05:00
										 |  |  | #include <QByteArray>
 | 
					
						
							|  |  |  | #include <QCache>
 | 
					
						
							|  |  |  | #include <QScopedPointer>
 | 
					
						
							| 
									
										
										
										
											2019-10-08 14:33:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-15 13:52:30 -04:00
										 |  |  | #include "AudioDevice.hpp"
 | 
					
						
							|  |  |  | #include "AudioDecoder.h"
 | 
					
						
							| 
									
										
										
										
											2019-11-21 11:49:17 -05:00
										 |  |  | #include "Audio/BWFFile.hpp"
 | 
					
						
							| 
									
										
										
										
											2019-10-15 13:52:30 -04:00
										 |  |  | #include "soundout.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-16 22:28:45 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-15 13:52:30 -04:00
										 |  |  | class NotificationAudio : | 
					
						
							|  |  |  |     public QObject | 
					
						
							| 
									
										
										
										
											2019-10-08 14:33:38 -04:00
										 |  |  | { | 
					
						
							|  |  |  |     Q_OBJECT | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     NotificationAudio(QObject * parent=nullptr); | 
					
						
							| 
									
										
										
										
											2019-10-08 21:26:17 -04:00
										 |  |  |     ~NotificationAudio(); | 
					
						
							| 
									
										
										
										
											2019-10-08 14:33:38 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | public slots: | 
					
						
							| 
									
										
										
										
											2019-11-21 11:49:17 -05:00
										 |  |  |     void status(QString message); | 
					
						
							|  |  |  |     void error(QString message); | 
					
						
							| 
									
										
										
										
											2019-10-15 13:52:30 -04:00
										 |  |  |     void setDevice(const QAudioDeviceInfo &device, unsigned channels, unsigned msBuffer=0); | 
					
						
							| 
									
										
										
										
											2019-10-08 14:33:38 -04:00
										 |  |  |     void play(const QString &filePath); | 
					
						
							|  |  |  |     void stop(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2019-11-26 14:23:39 -05:00
										 |  |  |     void playBytes(const QAudioFormat &format, QByteArray *bytes); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     QMap<QString, QPair<QAudioFormat, QByteArray*>> m_cache; | 
					
						
							| 
									
										
										
										
											2019-10-15 13:52:30 -04:00
										 |  |  |     QPointer<SoundOutput> m_stream; | 
					
						
							|  |  |  |     QPointer<AudioDecoder> m_decoder; | 
					
						
							| 
									
										
										
										
											2019-11-21 11:49:17 -05:00
										 |  |  |     QPointer<BWFFile> m_file; | 
					
						
							| 
									
										
										
										
											2019-10-16 22:28:45 -04:00
										 |  |  |     QAudioDeviceInfo m_device; | 
					
						
							| 
									
										
										
										
											2019-11-26 14:23:39 -05:00
										 |  |  |     QBuffer m_buffer; | 
					
						
							| 
									
										
										
										
											2019-10-16 22:28:45 -04:00
										 |  |  |     unsigned m_channels; | 
					
						
							|  |  |  |     unsigned m_msBuffer; | 
					
						
							| 
									
										
										
										
											2019-10-08 14:33:38 -04:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif // NOTIFICATIONAUDIO_H
 |