1 /*
2                                     __
3                                    / _|
4   __ _ _   _ _ __ ___  _ __ __ _  | |_ ___  ___ ___
5  / _` | | | | '__/ _ \| '__/ _` | |  _/ _ \/ __/ __|
6 | (_| | |_| | | | (_) | | | (_| | | || (_) \__ \__ \
7  \__,_|\__,_|_|  \___/|_|  \__,_| |_| \___/|___/___/
8 
9 Copyright (C) 2018-2019 Aurora Free Open Source Software.
10 
11 This file is part of the Aurora Free Open Source Software. This
12 organization promote free and open source software that you can
13 redistribute and/or modify under the terms of the GNU Lesser General
14 Public License Version 3 as published by the Free Software Foundation or
15 (at your option) any later version approved by the Aurora Free Open Source
16 Software Organization. The license is available in the package root path
17 as 'LICENSE' file. Please review the following information to ensure the
18 GNU Lesser General Public License version 3 requirements will be met:
19 https://www.gnu.org/licenses/lgpl.html .
20 
21 Alternatively, this file may be used under the terms of the GNU General
22 Public License version 3 or later as published by the Free Software
23 Foundation. Please review the following information to ensure the GNU
24 General Public License requirements will be met:
25 http://www.gnu.org/licenses/gpl-3.0.html.
26 
27 NOTE: All products, services or anything associated to trademarks and
28 service marks used or referenced on this file are the property of their
29 respective companies/owners or its subsidiaries. Other names and brands
30 may be claimed as the property of others.
31 
32 For more info about intellectual property visit: aurorafoss.org or
33 directly send an email to: contact (at) aurorafoss.org .
34 */
35 
36 module aurorafw.audio.input;
37 
38 import aurorafw.audio.utils : AudioInfo;
39 import riverd.sndfile;
40 
41 import aurorafw.stdx..string : toStringz;
42 import aurorafw.stdx.exception;
43 
44 protected int audioInputCallback() {
45 	//TODO: Need implementation
46 	throw new NotImplementedException("Not yet implemented!");
47 }
48 
49 class AudioIStream {
50 	this(const string path, AudioInfo audioInfo, int bufferSize) {
51 		this.path = path;
52 		this.audioInfo = audioInfo;
53 		this.bufferSize = bufferSize;
54 
55 		buffer = new float[bufferSize * audioInfo.channels];
56 
57 		audioInfo._sndFile = sf_open(path.toStringz, SFM_WRITE, audioInfo._sndInfo);
58 
59 		// soundio_write_stream(...);
60 		//TODO: Need implementation
61 		throw new NotImplementedException("Not yet implemented!");
62 	}
63 
64 	void record() {
65 		//TODO: Need implementation
66 		throw new NotImplementedException("Not yet implemented!");
67 		//soundio_start_stream(...);
68 	}
69 
70 	void pause() {
71 		//TODO: Need implementation
72 		throw new NotImplementedException("Not yet implemented!");
73 		//soundio_stop_stream(...);
74 	}
75 
76 	void stop() {
77 		//TODO: Need implementation
78 		throw new NotImplementedException("Not yet implemented!");
79 		//_streamPosFrame = 0;
80 
81 		//soundio_stop_stream(...);
82 	}
83 
84 	bool isRecording() {
85 		//TODO: Need implementation
86 		throw new NotImplementedException("Not yet implemented!");
87 		//return soundio_is_stream_active(...);
88 	}
89 
90 	bool isPaused() {
91 		//TODO: Need implementation
92 		throw new NotImplementedException("Not yet implemented!");
93 		//return !soundio_is_stream_active(...) && _streamPosFrame != 0;
94 	}
95 
96 	bool isStopped() {
97 		//TODO: Need implementation
98 		throw new NotImplementedException("Not yet implemented!");
99 		//return !soundio_is_stream_active(...)
100 	}
101 
102 	bool isBufferFull() {
103 		//TODO: Need implementation
104 		throw new NotImplementedException("Not yet implemented!");
105 	}
106 	void clearBuffer() {
107 		//TODO: Need implementation
108 		throw new NotImplementedException("Not yet implemented!");
109 	}
110 
111 	void clearBuffer(uint start, uint finish) {
112 		//TODO: Need implementation
113 		throw new NotImplementedException("Not yet implemented!");
114 	}
115 
116 	bool save() {
117 		if(sf_write_float(audioInfo._sndFile, buffer.ptr, bufferSize) == -1)
118 			return false;
119 		return true;
120 	}
121 
122 	immutable string path;
123 	AudioInfo audioInfo;
124 	//TODO: Define wether the buffer should be public or private
125 	float[] buffer;
126 	immutable uint bufferSize;
127 
128 private:
129 	//soundioStream soundioStream;
130 	uint _streamPosFrame;
131 }