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 aurorafw.core.debugmanager; 40 import aurorafw.audio.sndfile; 41 42 import std.string : toStringz; 43 44 protected int audioInputCallback() { 45 pragma(msg, debugMsgPrefix, "TODO: Implement audioInputCallback()"); 46 return 0; 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 pragma(msg, debugMsgPrefix, "TODO: Implement AudioIStream ctor()"); 61 } 62 63 void record() { 64 pragma(msg, debugMsgPrefix, "TODO: Implement record()"); 65 //soundio_start_stream(...); 66 } 67 68 void pause() { 69 pragma(msg, debugMsgPrefix, "TODO: Implement pause()"); 70 //soundio_stop_stream(...); 71 } 72 73 void stop() { 74 pragma(msg, debugMsgPrefix, "TODO: Implement stop()"); 75 _streamPosFrame = 0; 76 77 //soundio_stop_stream(...); 78 } 79 80 bool isRecording() { 81 pragma(msg, debugMsgPrefix, "TODO: Implement isRecording()"); 82 //return soundio_is_stream_active(...); 83 return 0; 84 } 85 86 bool isPaused() { 87 pragma(msg, debugMsgPrefix, "TODO: Implement isPaused()"); 88 //return !soundio_is_stream_active(...) && _streamPosFrame != 0; 89 return 0; 90 } 91 92 bool isStopped() { 93 pragma(msg, debugMsgPrefix, "TODO: Implement isStopped()"); 94 //return !soundio_is_stream_active(...) 95 return 0; 96 } 97 98 bool isBufferFull() { 99 pragma(msg, debugMsgPrefix, "TODO: Implement isBufferFull()"); 100 return 0; 101 } 102 void clearBuffer() { 103 pragma(msg, debugMsgPrefix, "TODO: Implement clearBuffer()"); 104 } 105 106 void clearBuffer(uint start, uint finish) { 107 pragma(msg, debugMsgPrefix, "TODO: Implement clearBuffer(uint start, uint finish)"); 108 } 109 110 bool save() { 111 if(sf_write_float(audioInfo._sndFile, buffer.ptr, bufferSize) == -1) 112 return false; 113 return true; 114 } 115 116 immutable string path; 117 AudioInfo audioInfo; 118 pragma(msg, debugMsgPrefix, "TODO: Define wether the buffer should be public or private"); 119 float[] buffer; 120 immutable uint bufferSize; 121 122 private: 123 //soundioStream soundioStream; 124 uint _streamPosFrame; 125 }