fanch před 1 rokem
rodič
revize
02d565c2c9

+ 10 - 0
.gitignore

@@ -1,2 +1,12 @@
 /Debug/
 /debug/
+/vgcore.19164
+/vgcore.19400
+/vgcore.19806
+/vgcore.20198
+/vgcore.21641
+/vgcore.4735
+/vgcore.4983
+/vgcore.5203
+/vgcore.5309
+/vgcore.5457

+ 150 - 0
src/core/NoteSpectrum.cpp

@@ -0,0 +1,150 @@
+/*
+ * NoteSpectrum.cpp
+ *
+ *  Created on: 27 déc. 2023
+ *      Author: fanch
+ */
+
+#include "NoteSpectrum.h"
+
+NoteSpectrum::NoteSpectrum() {
+	// TODO Auto-generated constructor stub
+
+}
+
+NoteSpectrum::~NoteSpectrum() {
+	// TODO Auto-generated destructor stub
+}
+
+
+
+const Note Notes[128] = {
+		Note(0),
+		Note(1),
+		Note(2),
+		Note(3),
+		Note(4),
+		Note(5),
+		Note(6),
+		Note(7),
+		Note(8),
+		Note(9),
+		Note(10),
+		Note(11),
+		Note(12),
+		Note(13),
+		Note(14),
+		Note(15),
+		Note(16),
+		Note(17),
+		Note(18),
+		Note(19),
+		Note(20),
+		Note(21),
+		Note(22),
+		Note(23),
+		Note(24),
+		Note(25),
+		Note(26),
+		Note(27),
+		Note(28),
+		Note(29),
+		Note(30),
+		Note(31),
+		Note(32),
+		Note(33),
+		Note(34),
+		Note(35),
+		Note(36),
+		Note(37),
+		Note(38),
+		Note(39),
+		Note(40),
+		Note(41),
+		Note(42),
+		Note(43),
+		Note(44),
+		Note(45),
+		Note(46),
+		Note(47),
+		Note(48),
+		Note(49),
+		Note(50),
+		Note(51),
+		Note(52),
+		Note(53),
+		Note(54),
+		Note(55),
+		Note(56),
+		Note(57),
+		Note(58),
+		Note(59),
+		Note(60),
+		Note(61),
+		Note(62),
+		Note(63),
+		Note(64),
+		Note(65),
+		Note(66),
+		Note(67),
+		Note(68),
+		Note(69),
+		Note(70),
+		Note(71),
+		Note(72),
+		Note(73),
+		Note(74),
+		Note(75),
+		Note(76),
+		Note(77),
+		Note(78),
+		Note(79),
+		Note(80),
+		Note(81),
+		Note(82),
+		Note(83),
+		Note(84),
+		Note(85),
+		Note(86),
+		Note(87),
+		Note(88),
+		Note(89),
+		Note(90),
+		Note(91),
+		Note(92),
+		Note(93),
+		Note(94),
+		Note(95),
+		Note(96),
+		Note(97),
+		Note(98),
+		Note(99),
+		Note(100),
+		Note(101),
+		Note(102),
+		Note(103),
+		Note(104),
+		Note(105),
+		Note(106),
+		Note(107),
+		Note(108),
+		Note(109),
+		Note(110),
+		Note(111),
+		Note(112),
+		Note(113),
+		Note(114),
+		Note(115),
+		Note(116),
+		Note(117),
+		Note(118),
+		Note(119),
+		Note(120),
+		Note(121),
+		Note(122),
+		Note(123),
+		Note(124),
+		Note(125),
+		Note(126),
+		Note(127)
+};

+ 47 - 0
src/core/NoteSpectrum.h

@@ -0,0 +1,47 @@
+/*
+ * NoteSpectrum.h
+ *
+ *  Created on: 27 déc. 2023
+ *      Author: fanch
+ */
+
+#ifndef SRC_PLUGINS_NOTESPECTRUM_H_
+#define SRC_PLUGINS_NOTESPECTRUM_H_
+#include <string>
+#include <cstdint>
+#include <cstring>
+#include <cmath>
+
+
+struct Note {
+	constexpr static const char NOTE_LETTERS[12][3]  = {"A", "A#", "B", "C", "C#", "D", "D#",  "E", "F", "F#", "G", "G#"};
+	const uint8_t NOTE_COUNT = 12;
+	std::string fullname;
+	uint8_t note;
+	int8_t octave;
+	const char* letter;
+	float frequency;
+	uint8_t midi;
+
+	Note(int m){
+		midi = m;
+		frequency = 440.0 * pow(2, (midi-69)/12);
+		octave = midi /12-1;
+		note = (midi+3) % 12;
+		letter = NOTE_LETTERS[note];
+	}
+};
+
+
+
+extern const Note Notes[128];
+
+
+
+class NoteSpectrum {
+public:
+	NoteSpectrum();
+	virtual ~NoteSpectrum();
+};
+
+#endif /* SRC_PLUGINS_NOTESPECTRUM_H_ */

+ 1 - 0
src/core/PluginInstance.cpp

@@ -30,6 +30,7 @@ PluginInstance::PluginInstance(PluginManager& manager, PluginEntry& entry, int i
 }
 
 PluginInstance::~PluginInstance(){
+	m_desc->cleanup(m_instance);
 	DllManager::close(m_dll);
 }
 

+ 1 - 1
src/core/PluginManager.cpp

@@ -19,7 +19,7 @@ PluginManager::~PluginManager(){
 	}
 	m_buffers.clear();
 	if(m_input) delete[] m_input;
-	if(m_output) delete[] m_input;
+	if(m_output) delete[] m_output;
 }
 
 void PluginManager::connect(PluginInstance *p1, int p1id, PluginInstance *p2,

+ 1 - 0
src/core/wscript

@@ -3,6 +3,7 @@ core_sources = [
         "PluginHost.cpp",
         "PluginInstance.cpp",
         "PluginManager.cpp",
+        "NoteSpectrum.cpp"
 ]
 
 

+ 2 - 2
src/io/FileSoundInput.cpp

@@ -21,8 +21,8 @@ FileSoundInput::FileSoundInput(const std::string &path, unsigned int sc) {
 	m_sample_rate = info.samplerate;
 	m_sample_size = info.format;
 	m_sample_count = sc;
-	m_buffer = new LADSPA_Data[m_channels * sc];
-	init(sc);
+	m_buffer = NULL;
+	init(m_sample_count);
 }
 int icount = 0;
 FileSoundInput::~FileSoundInput() {

+ 1 - 2
src/io/FileSoundInput.h

@@ -16,7 +16,7 @@
 class FileSoundInput : public SoundInputStream {
 public:
 	FileSoundInput(const std::string& path, unsigned int sample_cout);
-	~FileSoundInput();
+	virtual ~FileSoundInput();
 
 
 	void close();
@@ -25,7 +25,6 @@ protected:
 	virtual LADSPA_Data* _next(LADSPA_Data*);
 	std::string m_path;
 	SNDFILE*	m_fd;
-	LADSPA_Data* m_buffer;
 
 };
 

+ 3 - 1
src/io/SoundInput.h

@@ -13,7 +13,9 @@
 
 class SoundInputStream {
 public:
-	~SoundInputStream(){}
+	virtual ~SoundInputStream(){
+		if(m_buffer) delete[] m_buffer;
+	}
 
 	enum Type {
 		REALTIME,

+ 0 - 1
src/plugins/AudiToMidi.cpp

@@ -223,7 +223,6 @@ static void run(LADSPA_Handle Instance, unsigned long SampleCount){
 
 
 static void cleanup(LADSPA_Handle insatnce){
-	printf("cleanup\n");
 	delete (AudiToMidi *)insatnce;
 }
 

+ 2 - 5
src/plugins/TestPlugin.cpp

@@ -13,10 +13,9 @@ int main(int argc, char** argv){
 	try {
 		TestPlugin plugins;
 		plugins.host.add_path("/home/fanch/Programmation/audio_renderer/debug/src/plugins/");
-		//plugins.host.add_path("/usr/lib/ladspa");
 		plugins.host.update();
 		PluginEntry& plugin = plugins.host.load_from_path("/home/fanch/Programmation/audio_renderer/debug/src/plugins/libaudio_to_midi.so");
-		//printf("Add plugin\n");
+
 		FileSoundInput fsi("/home/fanch/Programmation/LADSPA/audio_to_midi/snd/yafs1.wav", SAMPLE_WINDOW);
 
 		plugins.manager.set_rate(44100, SAMPLE_WINDOW);
@@ -28,12 +27,10 @@ int main(int argc, char** argv){
 		while ((buffer = fsi.next(buffer))){
 			plugins.manager.run(buffer);
 			count ++;
-			if(count>1000){
+			if(count>10){
 				break;
 			}
 		}
-		printf("fin\n");
-		delete[] buffer;
 
 	} catch (const char* x) {
 		printf("Erreur: %s\n", x);

+ 5 - 0
tests/plugins/test_plugins_1.cpp

@@ -1,6 +1,7 @@
 #include "tests.h"
 
 waf_test_use("plugin_base")
+waf_test_lib("gtest", "gmock", "gtest_main", "gmock_main", "pthread")
 
 #include "core/PluginIndex.h"
 #include "core/PluginManager.h"
@@ -18,6 +19,10 @@ struct TestPlugin {
 
 
 #define SAMPLE_WINDOW 4096
+TEST(SomeTest, ABasicTest) {
+  EXPECT_EQ(1, 1);
+}
+
 int main(int argc, char** argv){
 	try {
 		TestPlugin plugins;

+ 4 - 0
tests/tests.h

@@ -9,6 +9,10 @@
 #define TESTS_TESTS_H_
 
 #define waf_test_use(...)
+#define waf_test_lib(...)
+#define waf_test_uselib(...)
+#include <gtest/gtest.h>
+
 
 
 

+ 11 - 1
wscript

@@ -71,10 +71,19 @@ class TestRecognizer:
     def execute_use(self, data):
         self._add_or_append("use", data)
     
+    def execute_lib(self, data):
+        self._add_or_append("lib", data)
+    
+    def execute_uselib(self, data):
+        self._add_or_append("uselib", data)
+    
     def add_test(self):
         content = Path(self.file).read_text()
+        find = False
         for x in self.RE_FIND_WAF_INFO.finditer(content):
+            find = True
             self.recognize(content, x)
+        if not find: return 
         
         print(f"add program :  {self.target}")
         self.bld.program(**self.target)
@@ -135,4 +144,5 @@ def build(bld):
                 lib=['fftw3', "sndfile"], 
                 use=["common", "fft", "io"])
 
-
+def test(bld):
+    pass