summaryrefslogtreecommitdiff
path: root/src/core/kernelAudio.h
blob: a4673f26119fba825a7d484c115fdb028a5410d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/* ---------------------------------------------------------------------
 *
 * Giada - Your Hardcore Loopmachine
 *
 * KernelAudio
 *
 * ---------------------------------------------------------------------
 *
 * Copyright (C) 2010-2015 Giovanni A. Zuliani | Monocasual
 *
 * This file is part of Giada - Your Hardcore Loopmachine.
 *
 * Giada - Your Hardcore Loopmachine 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 3 of the License, or (at your option) any later version.
 *
 * Giada - Your Hardcore Loopmachine 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 Giada - Your Hardcore Loopmachine. If not, see
 * <http://www.gnu.org/licenses/>.
 *
 * ------------------------------------------------------------------ */


#ifndef KERNELAUDIO_H
#define KERNELAUDIO_H


#include "../deps/rtaudio-mod/RtAudio.h"
#if defined(__linux__)
	#include <jack/jack.h>
	#include <jack/intclient.h>
	#include <jack/transport.h>
#endif


namespace kernelAudio {

	int openDevice(
			int api,
			int outDev,
			int inDev,
			int outChan,
			int inChan,
			int samplerate,
			int buffersize);
	int closeDevice();

	int startStream();
	int stopStream();

	bool			  isProbed       (unsigned dev);
	bool		    isDefaultIn    (unsigned dev);
	bool			  isDefaultOut   (unsigned dev);
	const char *getDeviceName  (unsigned dev);
	unsigned    getMaxInChans  (int dev);
	unsigned    getMaxOutChans (unsigned dev);
	unsigned    getDuplexChans (unsigned dev);
	int         getTotalFreqs  (unsigned dev);
	int					getFreq        (unsigned dev, int i);
	int					getDeviceByName(const char *name);
	int         getDefaultOut  ();
	int         getDefaultIn   ();
	bool        hasAPI         (int API);

	std::string getRtAudioVersion();

#ifdef __linux__
	jack_client_t *jackGetHandle();
	void jackStart();
	void jackStop();
	void jackSetSyncCb();
	int  jackSyncCb(jack_transport_state_t state, jack_position_t *pos, void *arg);
#endif

	/* *** how to avoid multiple definition of ***
	 * When you declare a variable in a header file, every source file that
	 * includes that header, either directly or indirectly, gets its own
	 * separate copy of the variable. Then when you go to link all the .o
	 * files together, the linker sees that the variable is instantiated
	 * in a bunch of .o files. Make it extern in the header file and
	 * instantiate it in memory.cpp. */

	extern RtAudio  *system;
	extern unsigned  numDevs;
	extern bool 		 inputEnabled;
	extern unsigned  realBufsize; 		// reale bufsize from the soundcard
	extern int       api;
}

#endif