├── .gitignore ├── LICENSE ├── Makefile ├── Makefile.converter ├── Makefile.demo ├── Makefile.standalone ├── Makefile.vstlinux ├── Makefile.vstmacosx ├── Makefile.vstwindows ├── README.md ├── skins ├── default │ ├── bg.bmp │ ├── buttons.bmp │ ├── chars.bmp │ ├── key.bmp │ ├── knob.bmp │ ├── knob2.bmp │ ├── knob3.bmp │ └── ops.bmp ├── dx7 │ ├── bg.bmp │ ├── buttons.bmp │ ├── chars.bmp │ ├── key.bmp │ ├── knob.bmp │ ├── knob2.bmp │ ├── knob3.bmp │ └── ops.bmp ├── fm8like │ ├── bg.bmp │ ├── buttons.bmp │ ├── chars.bmp │ ├── key.bmp │ ├── knob.bmp │ ├── knob2.bmp │ ├── knob3.bmp │ ├── ops.bmp │ └── readme.txt ├── lcd │ ├── bg.bmp │ ├── buttons.bmp │ ├── chars.bmp │ ├── key.bmp │ ├── knob.bmp │ ├── knob2.bmp │ ├── knob3.bmp │ └── ops.bmp ├── snow │ ├── bg.bmp │ ├── buttons.bmp │ ├── chars.bmp │ ├── key.bmp │ ├── knob.bmp │ ├── knob2.bmp │ ├── knob3.bmp │ └── ops.bmp ├── totolitoto │ ├── bg.bmp │ ├── buttons.bmp │ ├── chars.bmp │ ├── key.bmp │ ├── knob.bmp │ ├── knob2.bmp │ ├── knob3.bmp │ └── ops.bmp └── tx802 │ ├── bg.bmp │ ├── buttons.bmp │ ├── chars.bmp │ ├── key.bmp │ ├── knob.bmp │ ├── knob2.bmp │ ├── knob3.bmp │ └── ops.bmp └── src ├── converter ├── converter.c └── testtune.mid ├── demo ├── controller.cpp ├── controller.h ├── main.cpp ├── soundbank.h ├── tune.h ├── tunereader.cpp └── tunereader.h ├── gui ├── button.cpp ├── button.h ├── channels.cpp ├── channels.h ├── control.h ├── editor.cpp ├── editor.h ├── key.cpp ├── key.h ├── knob.cpp ├── knob.h ├── lcd.cpp ├── lcd.h ├── mapper.cpp └── mapper.h ├── macosx ├── app │ ├── Info.plist │ └── PkgInfo └── vst │ ├── Info.plist │ └── PkgInfo ├── standalone └── main.cpp ├── synth ├── bank0.bin ├── bank0.h ├── bank1.bin ├── bank1.h ├── buffers.cpp ├── buffers.h ├── constants.h ├── delay.cpp ├── delay.h ├── envelop.cpp ├── envelop.h ├── filter.cpp ├── filter.h ├── noise.cpp ├── noise.h ├── note.cpp ├── note.h ├── oscillator.cpp ├── oscillator.h ├── persist.cpp ├── persist.h ├── programs.cpp ├── programs.h ├── reverb.cpp ├── reverb.h ├── synthesizer.cpp └── synthesizer.h ├── toolkits ├── bitmaps.h ├── cocoatoolkit.cpp ├── cocoatoolkit.h ├── cocoatoolkit.m ├── cocoawrapper.h ├── embedresources.cpp ├── hostinterface.h ├── nonguitoolkit.cpp ├── nonguitoolkit.h ├── opengltoolkit.cpp ├── opengltoolkit.h ├── ostoolkit.h ├── toolkit.h ├── windowstoolkit.cpp ├── windowstoolkit.h ├── xlibtoolkit.cpp └── xlibtoolkit.h ├── vst ├── oxevst.cpp ├── oxevst.h ├── oxevsteditor.cpp ├── oxevsteditor.h ├── oxevstmain.cpp ├── vsthostinterface.cpp └── vsthostinterface.h └── windows ├── icon.ico ├── resources.h └── resources.rc /.gitignore: -------------------------------------------------------------------------------- 1 | *.exe 2 | *.wav 3 | *.dll 4 | *.so 5 | *.o 6 | bitmaps.cpp 7 | oxefmsynthdemo 8 | oxeconverter 9 | oxefmsynth 10 | oxefmsynth.app 11 | oxefmsynth.vst 12 | .DS_Store 13 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Oxe FM Synth: a software synthesizer 2 | # Copyright (C) 2015 Daniel Moura 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see . 16 | 17 | UNAME_S:=$(shell uname -s) 18 | 19 | all: 20 | @echo "Building converter" 21 | @$(MAKE) -s -f Makefile.converter 22 | @echo "Building demo" 23 | @$(MAKE) -s -f Makefile.demo 24 | @echo "Building standalone" 25 | @$(MAKE) -s -f Makefile.standalone 26 | ifeq ($(OS),Windows_NT) 27 | @echo "Building Windows VST plugin (32 and 64 bit)" 28 | @$(MAKE) -s -f Makefile.vstwindows 29 | endif 30 | ifeq ($(UNAME_S),Linux) 31 | @echo "Building Linux VST plugin" 32 | @$(MAKE) -s -f Makefile.vstlinux 33 | endif 34 | ifeq ($(UNAME_S),Darwin) 35 | @echo "Building OSX VST plugin" 36 | @$(MAKE) -s -f Makefile.vstmacosx 37 | endif 38 | 39 | clean: 40 | @rm -rf oxeconverter oxefmsynthdemo oxefmsynthdemo.exe oxefmsynthdemo.wav oxefmsynth oxefmsynth.exe oxevst*.dll oxevst*.so embedresources bitmaps.cpp *.o *.d oxefmsynth.app oxefmsynth.vst 41 | -------------------------------------------------------------------------------- /Makefile.converter: -------------------------------------------------------------------------------- 1 | # Oxe FM Synth: a software synthesizer 2 | # Copyright (C) 2015 Daniel Moura 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see . 16 | 17 | ifeq ($(OS),Windows_NT) 18 | CC:=i686-w64-mingw32-gcc.exe 19 | endif 20 | 21 | all: 22 | @$(CC) $(CFLAGS) -o oxeconverter src/converter/converter.c 23 | 24 | clean: 25 | @rm -f oxeconverter 26 | -------------------------------------------------------------------------------- /Makefile.demo: -------------------------------------------------------------------------------- 1 | # Oxe FM Synth: a software synthesizer 2 | # Copyright (C) 2015 Daniel Moura 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see . 16 | 17 | EXECUTABLE_NAME:=oxefmsynthdemo 18 | 19 | INCLUDES+=-Isrc/demo 20 | INCLUDES+=-Isrc/synth 21 | INCLUDES+=-Isrc/toolkits 22 | 23 | SOURCES+=src/toolkits/nonguitoolkit.cpp 24 | SOURCES+=src/demo/controller.cpp 25 | SOURCES+=src/demo/main.cpp 26 | SOURCES+=src/demo/tunereader.cpp 27 | SOURCES+=src/synth/buffers.cpp 28 | SOURCES+=src/synth/delay.cpp 29 | SOURCES+=src/synth/envelop.cpp 30 | SOURCES+=src/synth/filter.cpp 31 | SOURCES+=src/synth/note.cpp 32 | SOURCES+=src/synth/oscillator.cpp 33 | SOURCES+=src/synth/programs.cpp 34 | SOURCES+=src/synth/reverb.cpp 35 | SOURCES+=src/synth/noise.cpp 36 | SOURCES+=src/synth/synthesizer.cpp 37 | 38 | ifeq ($(DEBUG),YES) 39 | CXXFLAGS+=-g -O0 40 | else 41 | CXXFLAGS+=-O3 42 | endif 43 | 44 | ifeq ($(PROFILING),YES) 45 | CXXFLAGS+=-D__RENDER_TO_MEMORY__ONLY__ 46 | #CXXFLAGS+=-nostdlib 47 | endif 48 | 49 | ifeq ($(WITH_DSOUND),YES) 50 | CXXFLAGS+=-D__WITH_DSOUND__ 51 | LDFLAGS+=-ldsound 52 | endif 53 | 54 | ifeq ($(OS),Windows_NT) 55 | EXECUTABLE_NAME:=$(EXECUTABLE_NAME).exe 56 | CXX:=g++.exe 57 | LDFLAGS+=-s 58 | else 59 | ifeq ($(TARGET),WIN32) 60 | EXECUTABLE_NAME:=$(EXECUTABLE_NAME).exe 61 | CXX:=i686-w64-mingw32-g++ 62 | LDFLAGS+=-static -s 63 | else 64 | UNAME_S:=$(shell uname -s) 65 | ifneq ($(UNAME_S),Darwin) 66 | LDFLAGS+=-s 67 | endif 68 | endif 69 | endif 70 | 71 | all: 72 | @$(CXX) -o $(EXECUTABLE_NAME) -DEXECUTABLE_NAME=\"$(EXECUTABLE_NAME)\" -D__OXEDMO__ $(CXXFLAGS) $(SOURCES) $(INCLUDES) $(LDFLAGS) 73 | 74 | clean: 75 | @rm -f $(EXECUTABLE_NAME) *.wav 76 | -------------------------------------------------------------------------------- /Makefile.standalone: -------------------------------------------------------------------------------- 1 | # Oxe FM Synth: a software synthesizer 2 | # Copyright (C) 2015 Daniel Moura 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see . 16 | 17 | EXECUTABLE_NAME:=oxefmsynth 18 | 19 | INCLUDES+=-Isrc/vst 20 | INCLUDES+=-Isrc/gui 21 | INCLUDES+=-Isrc/synth 22 | INCLUDES+=-Isrc/toolkits 23 | 24 | SOURCES+=src/toolkits/nonguitoolkit.cpp 25 | SOURCES+=src/standalone/main.cpp 26 | SOURCES+=src/gui/button.cpp 27 | SOURCES+=src/gui/channels.cpp 28 | SOURCES+=src/gui/editor.cpp 29 | SOURCES+=src/gui/key.cpp 30 | SOURCES+=src/gui/knob.cpp 31 | SOURCES+=src/gui/lcd.cpp 32 | SOURCES+=src/gui/mapper.cpp 33 | SOURCES+=src/synth/buffers.cpp 34 | SOURCES+=src/synth/delay.cpp 35 | SOURCES+=src/synth/envelop.cpp 36 | SOURCES+=src/synth/filter.cpp 37 | SOURCES+=src/synth/noise.cpp 38 | SOURCES+=src/synth/note.cpp 39 | SOURCES+=src/synth/oscillator.cpp 40 | SOURCES+=src/synth/persist.cpp 41 | SOURCES+=src/synth/programs.cpp 42 | SOURCES+=src/synth/reverb.cpp 43 | SOURCES+=src/synth/synthesizer.cpp 44 | 45 | UNAME_S:=$(shell uname -s) 46 | 47 | ifeq ($(DEBUG),YES) 48 | CXXFLAGS+=-g -O0 49 | else 50 | CXXFLAGS+=-O3 51 | ifneq ($(UNAME_S),Darwin) 52 | LDFLAGS+=-s 53 | endif 54 | endif 55 | 56 | ifeq ($(OS),Windows_NT) 57 | EXECUTABLE_NAME:=$(EXECUTABLE_NAME).exe 58 | CXX:=g++.exe 59 | RC:=windres.exe 60 | INCLUDES+=-Isrc/standalone 61 | SOURCES+=src/toolkits/windowstoolkit.cpp 62 | INCLUDES+=-Isrc/windows 63 | LDFLAGS+=-lgdi32 64 | LDFLAGS+=resources.o 65 | DEPS:=resources.o 66 | else 67 | ifeq ($(TARGET),WIN32) 68 | EXECUTABLE_NAME:=$(EXECUTABLE_NAME).exe 69 | CXX:=i686-w64-mingw32-g++ 70 | RC:=i686-w64-mingw32-windres 71 | INCLUDES+=-Isrc/standalone 72 | SOURCES+=src/toolkits/windowstoolkit.cpp 73 | INCLUDES+=-Isrc/windows 74 | LDFLAGS+=-lgdi32 75 | LDFLAGS+=resources.o 76 | DEPS:=resources.o 77 | LDFLAGS+=-static 78 | else 79 | INCLUDES+=-I. 80 | DEPS:=bitmaps.cpp 81 | SOURCES+=bitmaps.cpp 82 | ifeq ($(UNAME_S),Darwin) 83 | LDFLAGS+=-framework Cocoa 84 | LDFLAGS+=-framework OpenGL 85 | SOURCES+=src/toolkits/opengltoolkit.cpp 86 | SOURCES+=src/toolkits/cocoatoolkit.cpp 87 | SOURCES+=src/toolkits/cocoatoolkit.m 88 | else 89 | LDFLAGS+=-lX11 90 | LDFLAGS+=-lpthread 91 | LDFLAGS+=-ldl 92 | ifeq ($(USE_OPENGL),YES) 93 | CXXFLAGS+=-DUSE_OPENGL 94 | LDFLAGS+=-lGL 95 | SOURCES+=src/toolkits/opengltoolkit.cpp 96 | endif 97 | SOURCES+=src/toolkits/xlibtoolkit.cpp 98 | endif 99 | endif 100 | endif 101 | 102 | all: $(DEPS) 103 | @$(CXX) -o $(EXECUTABLE_NAME) -DEXECUTABLE_NAME=\"$(EXECUTABLE_NAME)\" $(CXXFLAGS) $(SOURCES) $(INCLUDES) $(LDFLAGS) 104 | @$(CMD) 105 | ifeq ($(UNAME_S),Darwin) 106 | @mkdir -p $(EXECUTABLE_NAME).app/Contents/MacOS 107 | @cp src/macosx/app/* $(EXECUTABLE_NAME).app/Contents/ 108 | @mv $(EXECUTABLE_NAME) $(EXECUTABLE_NAME).app/Contents/MacOS/ 109 | endif 110 | 111 | bitmaps.cpp: 112 | @$(CXX) -o embedresources $(CXXFLAGS) src/toolkits/embedresources.cpp 113 | @./embedresources $@ 114 | @rm embedresources 115 | 116 | cocoatoolkit.o: 117 | @gcc -c -o $@ $(OBJCSOURCES) $(INCLUDES) $(OBJCXXFLAGS) 118 | 119 | resources.o: 120 | @$(RC) -Isrc/synth -Iskins/default src/windows/resources.rc resources.o 121 | 122 | clean: 123 | @rm -rf $(EXECUTABLE_NAME).app $(EXECUTABLE_NAME) embedresources bitmaps.cpp *.o *.d 124 | -------------------------------------------------------------------------------- /Makefile.vstlinux: -------------------------------------------------------------------------------- 1 | # Oxe FM Synth: a software synthesizer 2 | # Copyright (C) 2015 Daniel Moura 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see . 16 | 17 | ifeq ($(VSTSDK_PATH),) 18 | $(error Please set the VSTSDK_PATH environment variable to the vstsdk2.4 path) 19 | endif 20 | 21 | INCLUDES:=-Isrc/vst 22 | INCLUDES+=-Isrc/synth 23 | INCLUDES+=-Isrc/gui 24 | INCLUDES+=-Isrc/toolkits 25 | INCLUDES+=-I$(VSTSDK_PATH) 26 | INCLUDES+=-I. 27 | 28 | SOURCES:=src/vst/oxevst.cpp 29 | SOURCES+=src/vst/oxevstmain.cpp 30 | SOURCES+=src/vst/oxevsteditor.cpp 31 | SOURCES+=src/vst/vsthostinterface.cpp 32 | SOURCES+=src/toolkits/xlibtoolkit.cpp 33 | SOURCES+=src/gui/button.cpp 34 | SOURCES+=src/gui/channels.cpp 35 | SOURCES+=src/gui/editor.cpp 36 | SOURCES+=src/gui/key.cpp 37 | SOURCES+=src/gui/knob.cpp 38 | SOURCES+=src/gui/lcd.cpp 39 | SOURCES+=src/gui/mapper.cpp 40 | SOURCES+=src/synth/buffers.cpp 41 | SOURCES+=src/synth/delay.cpp 42 | SOURCES+=src/synth/envelop.cpp 43 | SOURCES+=src/synth/filter.cpp 44 | SOURCES+=src/synth/noise.cpp 45 | SOURCES+=src/synth/note.cpp 46 | SOURCES+=src/synth/oscillator.cpp 47 | SOURCES+=src/synth/persist.cpp 48 | SOURCES+=src/synth/programs.cpp 49 | SOURCES+=src/synth/reverb.cpp 50 | SOURCES+=src/synth/synthesizer.cpp 51 | SOURCES+=$(VSTSDK_PATH)/public.sdk/source/vst2.x/audioeffect.cpp 52 | SOURCES+=$(VSTSDK_PATH)/public.sdk/source/vst2.x/audioeffectx.cpp 53 | SOURCES+=$(VSTSDK_PATH)/public.sdk/source/vst2.x/vstplugmain.cpp 54 | SOURCES+=bitmaps.cpp 55 | 56 | LIBS:=-lX11 57 | LIBS+=-lpthread 58 | LIBS+=-ldl 59 | 60 | CXXFLAGS+=-fPIC -D__cdecl= 61 | 62 | ifeq ($(DEBUG),YES) 63 | CXXFLAGS+=-g -O0 64 | else 65 | CXXFLAGS+=-s -O3 66 | endif 67 | 68 | ARCH := $(shell getconf LONG_BIT) 69 | ifneq ($(ARCH),32) 70 | BITS:=-m32 71 | endif 72 | 73 | all: oxevst$(ARCH) 74 | 75 | oxevst32: bitmaps.cpp 76 | @$(CXX) -shared $(BITS) -o oxevst32.so $(CXXFLAGS) $(SOURCES) $(INCLUDES) $(LIBS) $(LDFLAGS) 77 | 78 | oxevst64: bitmaps.cpp 79 | @$(CXX) -shared -m64 -o oxevst64.so $(CXXFLAGS) $(SOURCES) $(INCLUDES) $(LIBS) $(LDFLAGS) 80 | 81 | bitmaps.cpp: 82 | @$(CXX) -o embedresources src/toolkits/embedresources.cpp $(CXXFLAGS) 83 | @./embedresources $@ 84 | @rm embedresources 85 | 86 | clean: 87 | @rm -f oxevst*.so embedresources resources.h 88 | -------------------------------------------------------------------------------- /Makefile.vstmacosx: -------------------------------------------------------------------------------- 1 | # Oxe FM Synth: a software synthesizer 2 | # Copyright (C) 2015 Daniel Moura 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see . 16 | 17 | ifeq ($(VSTSDK_PATH),) 18 | $(error Please set the VSTSDK_PATH environment variable to the vstsdk2.4 path) 19 | endif 20 | 21 | INCLUDES:=-Isrc/vst 22 | INCLUDES+=-Isrc/synth 23 | INCLUDES+=-Isrc/gui 24 | INCLUDES+=-Isrc/toolkits 25 | INCLUDES+=-I$(VSTSDK_PATH) 26 | INCLUDES+=-I. 27 | 28 | SOURCES:=src/vst/oxevst.cpp 29 | SOURCES+=src/vst/oxevstmain.cpp 30 | SOURCES+=src/vst/oxevsteditor.cpp 31 | SOURCES+=src/vst/vsthostinterface.cpp 32 | SOURCES+=src/toolkits/opengltoolkit.cpp 33 | SOURCES+=src/toolkits/cocoatoolkit.cpp 34 | SOURCES+=src/toolkits/cocoatoolkit.m 35 | SOURCES+=src/gui/button.cpp 36 | SOURCES+=src/gui/channels.cpp 37 | SOURCES+=src/gui/editor.cpp 38 | SOURCES+=src/gui/key.cpp 39 | SOURCES+=src/gui/knob.cpp 40 | SOURCES+=src/gui/lcd.cpp 41 | SOURCES+=src/gui/mapper.cpp 42 | SOURCES+=src/synth/buffers.cpp 43 | SOURCES+=src/synth/delay.cpp 44 | SOURCES+=src/synth/envelop.cpp 45 | SOURCES+=src/synth/filter.cpp 46 | SOURCES+=src/synth/noise.cpp 47 | SOURCES+=src/synth/note.cpp 48 | SOURCES+=src/synth/oscillator.cpp 49 | SOURCES+=src/synth/persist.cpp 50 | SOURCES+=src/synth/programs.cpp 51 | SOURCES+=src/synth/reverb.cpp 52 | SOURCES+=src/synth/synthesizer.cpp 53 | SOURCES+=$(VSTSDK_PATH)/public.sdk/source/vst2.x/audioeffect.cpp 54 | SOURCES+=$(VSTSDK_PATH)/public.sdk/source/vst2.x/audioeffectx.cpp 55 | SOURCES+=$(VSTSDK_PATH)/public.sdk/source/vst2.x/vstplugmain.cpp 56 | SOURCES+=bitmaps.cpp 57 | 58 | CFLAGS+=-framework Cocoa 59 | CFLAGS+=-framework OpenGL 60 | 61 | ifeq ($(DEBUG),YES) 62 | CFLAGS+=-g -O0 63 | else 64 | CFLAGS+=-O3 65 | endif 66 | 67 | BUNDLE_NAME:=oxefmsynth.vst 68 | BUNDLE_CONTENTS:=$(BUNDLE_NAME)/Contents 69 | BUNDLE_FULL_PATH:=$(BUNDLE_CONTENTS)/MacOS 70 | 71 | oxevst: bitmaps.cpp 72 | @mkdir -p $(BUNDLE_FULL_PATH) 73 | @cp src/macosx/vst/* $(BUNDLE_CONTENTS)/ 74 | @g++ -shared -o $(BUNDLE_FULL_PATH)/oxefmsynth $(CFLAGS) $(SOURCES) $(INCLUDES) $(LIBS) 75 | 76 | bitmaps.cpp: 77 | @$(CC) -o embedresources src/toolkits/embedresources.cpp 78 | @./embedresources $@ 79 | @rm embedresources 80 | 81 | clean: 82 | @rm -f $(BUNDLE_NAME) embedresources resources.h 83 | -------------------------------------------------------------------------------- /Makefile.vstwindows: -------------------------------------------------------------------------------- 1 | # Oxe FM Synth: a software synthesizer 2 | # Copyright (C) 2015 Daniel Moura 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see . 16 | 17 | ifeq ($(VSTSDK_PATH),) 18 | $(error Please set the VSTSDK_PATH environment variable to the vstsdk2.4 path) 19 | endif 20 | 21 | INCLUDES:=-Isrc/vst 22 | INCLUDES+=-Isrc/synth 23 | INCLUDES+=-Isrc/gui 24 | INCLUDES+=-Isrc/toolkits 25 | INCLUDES+=-Isrc/windows 26 | INCLUDES+=-I$(VSTSDK_PATH) 27 | 28 | SOURCES:=src/vst/oxevst.cpp 29 | SOURCES+=src/vst/oxevstmain.cpp 30 | SOURCES+=src/vst/oxevsteditor.cpp 31 | SOURCES+=src/vst/vsthostinterface.cpp 32 | SOURCES+=src/toolkits/windowstoolkit.cpp 33 | SOURCES+=src/gui/button.cpp 34 | SOURCES+=src/gui/channels.cpp 35 | SOURCES+=src/gui/editor.cpp 36 | SOURCES+=src/gui/key.cpp 37 | SOURCES+=src/gui/knob.cpp 38 | SOURCES+=src/gui/lcd.cpp 39 | SOURCES+=src/gui/mapper.cpp 40 | SOURCES+=src/synth/buffers.cpp 41 | SOURCES+=src/synth/delay.cpp 42 | SOURCES+=src/synth/envelop.cpp 43 | SOURCES+=src/synth/filter.cpp 44 | SOURCES+=src/synth/noise.cpp 45 | SOURCES+=src/synth/note.cpp 46 | SOURCES+=src/synth/oscillator.cpp 47 | SOURCES+=src/synth/persist.cpp 48 | SOURCES+=src/synth/programs.cpp 49 | SOURCES+=src/synth/reverb.cpp 50 | SOURCES+=src/synth/synthesizer.cpp 51 | SOURCES+=$(VSTSDK_PATH)/public.sdk/source/vst2.x/audioeffect.cpp 52 | SOURCES+=$(VSTSDK_PATH)/public.sdk/source/vst2.x/audioeffectx.cpp 53 | SOURCES+=$(VSTSDK_PATH)/public.sdk/source/vst2.x/vstplugmain.cpp 54 | 55 | LIBS:=-lgdi32 56 | 57 | ifeq ($(OS),Windows_NT) 58 | CC:=i686-w64-mingw32-g++.exe 59 | RC:=windres.exe 60 | CC64:=x86_64-w64-mingw32-g++.exe 61 | RC64:=windres.exe 62 | else 63 | CC:=i686-w64-mingw32-g++ 64 | RC:=i686-w64-mingw32-windres 65 | CC64:=x86_64-w64-mingw32-g++ 66 | RC64:=x86_64-w64-mingw32-windres 67 | CC:=i686-w64-mingw32-g++ 68 | RC:=i686-w64-mingw32-windres 69 | ifeq ($(shell which $(CC)),) 70 | $(error Please install mingw-w64.) 71 | endif 72 | endif 73 | 74 | all: oxevst32 oxevst64 75 | 76 | oxevst32: 77 | @$(RC) -Isrc/synth -Iskins/default src/windows/resources.rc resources32.o 78 | @$(CC) -static -s -O3 -shared -o oxevst.dll $(VSTSDK_PATH)/public.sdk/samples/vst2.x/win/vstplug.def $(CFLAGS) $(SOURCES) $(INCLUDES) $(LIBS) resources32.o 79 | @rm resources32.o 80 | 81 | oxevst64: 82 | @$(RC64) -Isrc/synth -Iskins/default src/windows/resources.rc resources64.o 83 | @$(CC64) -static -s -O3 -shared -o oxevst64.dll $(VSTSDK_PATH)/public.sdk/samples/vst2.x/win/vstplug.def $(CFLAGS) $(SOURCES) $(INCLUDES) $(LIBS) resources64.o 84 | @rm resources64.o 85 | 86 | clean: 87 | @rm -f oxevst*.dll 88 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Oxe FM Synth 2 | Welcome to the [Oxe FM Synth](https://oxesoft.wordpress.com/) official repository. 3 | 4 | ![defaultskin](https://oxesoft.files.wordpress.com/2007/12/screenshot_full.png) 5 | 6 | This repository contains the synth core and three different ways to use it: 7 | 8 | - as a [demo](https://en.wikipedia.org/wiki/Demoscene) (for testing synth engine, for profiling or just for fun) 9 | - as a standalone application (for testing GUI) 10 | - as a [VST plugin](https://pt.wikipedia.org/wiki/Virtual_Studio_Technology) for Windows (32/64bit), Linux 32/64bit and Mac OS X (64bit) 11 | 12 | ## Building 13 | 14 | ### Windows 15 | Requirements: [mingw-w64](http://mingw-w64.org/) and [msys](https://msysgit.github.io/). 16 | Install both 32 and 64bit (run the installer twice). 17 | On the msys shell just type ``mingw32-make``. 18 | 19 | ### Linux 20 | To build native executables just type ``make`` (requirement: g++). 21 | To build Windows executables on Ubuntu, type ``sudo apt-get install mingw-w64`` to install the required tools. 22 | 23 | ### Mac OS X 24 | On Xcode, install the "Command Line Tools" and type ``make`` on terminal. The Xcode IDE itself is not used. 25 | 26 | All the code is always compiled by once on purpose, to make sure everything is fine (because it is a tiny project). 27 | ``converter`` is a development tool for creating the demos. It converts a .mid file in a tune.h used for the demo player. 28 | 29 | ## Using the standalone 30 | While we are working on GUI (changing code or making skins) this standalone version helps a lot, 31 | because it is faster than open the plugin host, create a track, add the plugin, and so on. 32 | With the standalone version we reduce it in only one step. 33 | To cross-compile it for Windows, from Linux, run ``make -f Makefile.standalone TARGET=WIN32``. 34 | To build a native version, just type ``make -f Makefile.standalone``. 35 | 36 | 37 | ## Using the demo 38 | By default, a native plataform executable is generated. 39 | The tune can be rendered to a .wav file, to the memory (for profiling purposes) and, optionally, to the sound card in real time, using DirectSound. 40 | You can enable this building it with ``make -f Makefile.demo WITH_DSOUND=YES``. Once it is done, the default behaviour is to start playing. The command 41 | line parameters ``-f`` (to file) and ``-m`` (to memory) still works if used. 42 | To cross-compile it for Windows, from Linux, run ``make -f Makefile.demo TARGET=WIN32``. 43 | To build a native version, just type ``make -f Makefile.demo``. 44 | 45 | ## Skins 46 | To use a ready skin or test a new one, just put the images in a "skin" dir in the same dir as the plugin/standalone executable. 47 | 48 | ![skin1](https://oxesoft.files.wordpress.com/2015/04/layzer.png) 49 | 50 | ![skin2](https://oxesoft.files.wordpress.com/2017/05/snow1.png) 51 | 52 | ![skin3](https://oxesoft.files.wordpress.com/2015/08/totolitoto.png) 53 | 54 | ![skin4](https://oxesoft.files.wordpress.com/2015/05/tx802.png) 55 | 56 | ![skin5](https://oxesoft.files.wordpress.com/2015/10/dx7.png) 57 | 58 | ![skin6](https://oxesoft.files.wordpress.com/2017/05/fm8like1.png) 59 | -------------------------------------------------------------------------------- /skins/default/bg.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/default/bg.bmp -------------------------------------------------------------------------------- /skins/default/buttons.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/default/buttons.bmp -------------------------------------------------------------------------------- /skins/default/chars.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/default/chars.bmp -------------------------------------------------------------------------------- /skins/default/key.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/default/key.bmp -------------------------------------------------------------------------------- /skins/default/knob.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/default/knob.bmp -------------------------------------------------------------------------------- /skins/default/knob2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/default/knob2.bmp -------------------------------------------------------------------------------- /skins/default/knob3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/default/knob3.bmp -------------------------------------------------------------------------------- /skins/default/ops.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/default/ops.bmp -------------------------------------------------------------------------------- /skins/dx7/bg.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/dx7/bg.bmp -------------------------------------------------------------------------------- /skins/dx7/buttons.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/dx7/buttons.bmp -------------------------------------------------------------------------------- /skins/dx7/chars.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/dx7/chars.bmp -------------------------------------------------------------------------------- /skins/dx7/key.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/dx7/key.bmp -------------------------------------------------------------------------------- /skins/dx7/knob.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/dx7/knob.bmp -------------------------------------------------------------------------------- /skins/dx7/knob2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/dx7/knob2.bmp -------------------------------------------------------------------------------- /skins/dx7/knob3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/dx7/knob3.bmp -------------------------------------------------------------------------------- /skins/dx7/ops.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/dx7/ops.bmp -------------------------------------------------------------------------------- /skins/fm8like/bg.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/fm8like/bg.bmp -------------------------------------------------------------------------------- /skins/fm8like/buttons.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/fm8like/buttons.bmp -------------------------------------------------------------------------------- /skins/fm8like/chars.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/fm8like/chars.bmp -------------------------------------------------------------------------------- /skins/fm8like/key.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/fm8like/key.bmp -------------------------------------------------------------------------------- /skins/fm8like/knob.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/fm8like/knob.bmp -------------------------------------------------------------------------------- /skins/fm8like/knob2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/fm8like/knob2.bmp -------------------------------------------------------------------------------- /skins/fm8like/knob3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/fm8like/knob3.bmp -------------------------------------------------------------------------------- /skins/fm8like/ops.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/fm8like/ops.bmp -------------------------------------------------------------------------------- /skins/fm8like/readme.txt: -------------------------------------------------------------------------------- 1 | _______ _______ 2 | | /| /| / \ __ 3 | |_____ / | / | \_______/ | | | / | 4 | | / | / | / \ | | |< |-- 5 | | / |/ | \_______/ |__ | | \ |__ 6 | 7 | put the "skin" dir in the same dir as oxevst.dll/oxevst64.dll 8 | 9 | credits: Alvaax (Alan Wasky) -------------------------------------------------------------------------------- /skins/lcd/bg.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/lcd/bg.bmp -------------------------------------------------------------------------------- /skins/lcd/buttons.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/lcd/buttons.bmp -------------------------------------------------------------------------------- /skins/lcd/chars.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/lcd/chars.bmp -------------------------------------------------------------------------------- /skins/lcd/key.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/lcd/key.bmp -------------------------------------------------------------------------------- /skins/lcd/knob.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/lcd/knob.bmp -------------------------------------------------------------------------------- /skins/lcd/knob2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/lcd/knob2.bmp -------------------------------------------------------------------------------- /skins/lcd/knob3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/lcd/knob3.bmp -------------------------------------------------------------------------------- /skins/lcd/ops.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/lcd/ops.bmp -------------------------------------------------------------------------------- /skins/snow/bg.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/snow/bg.bmp -------------------------------------------------------------------------------- /skins/snow/buttons.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/snow/buttons.bmp -------------------------------------------------------------------------------- /skins/snow/chars.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/snow/chars.bmp -------------------------------------------------------------------------------- /skins/snow/key.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/snow/key.bmp -------------------------------------------------------------------------------- /skins/snow/knob.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/snow/knob.bmp -------------------------------------------------------------------------------- /skins/snow/knob2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/snow/knob2.bmp -------------------------------------------------------------------------------- /skins/snow/knob3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/snow/knob3.bmp -------------------------------------------------------------------------------- /skins/snow/ops.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/snow/ops.bmp -------------------------------------------------------------------------------- /skins/totolitoto/bg.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/totolitoto/bg.bmp -------------------------------------------------------------------------------- /skins/totolitoto/buttons.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/totolitoto/buttons.bmp -------------------------------------------------------------------------------- /skins/totolitoto/chars.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/totolitoto/chars.bmp -------------------------------------------------------------------------------- /skins/totolitoto/key.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/totolitoto/key.bmp -------------------------------------------------------------------------------- /skins/totolitoto/knob.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/totolitoto/knob.bmp -------------------------------------------------------------------------------- /skins/totolitoto/knob2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/totolitoto/knob2.bmp -------------------------------------------------------------------------------- /skins/totolitoto/knob3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/totolitoto/knob3.bmp -------------------------------------------------------------------------------- /skins/totolitoto/ops.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/totolitoto/ops.bmp -------------------------------------------------------------------------------- /skins/tx802/bg.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/tx802/bg.bmp -------------------------------------------------------------------------------- /skins/tx802/buttons.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/tx802/buttons.bmp -------------------------------------------------------------------------------- /skins/tx802/chars.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/tx802/chars.bmp -------------------------------------------------------------------------------- /skins/tx802/key.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/tx802/key.bmp -------------------------------------------------------------------------------- /skins/tx802/knob.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/tx802/knob.bmp -------------------------------------------------------------------------------- /skins/tx802/knob2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/tx802/knob2.bmp -------------------------------------------------------------------------------- /skins/tx802/knob3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/tx802/knob3.bmp -------------------------------------------------------------------------------- /skins/tx802/ops.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/skins/tx802/ops.bmp -------------------------------------------------------------------------------- /src/converter/testtune.mid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/src/converter/testtune.mid -------------------------------------------------------------------------------- /src/demo/controller.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifdef __WITH_DSOUND__ 20 | #define WIN32_LEAN_AND_MEAN 21 | #include 22 | #endif 23 | #include "controller.h" 24 | #include 25 | #include 26 | 27 | CController::CController() 28 | { 29 | tunePointer = 0; 30 | bufferPos = 0; 31 | nextPosition = 0; 32 | posExt = 0; 33 | posInt = 0; 34 | #ifdef __WITH_DSOUND__ 35 | lpDS = NULL; 36 | lplpDsb = NULL; 37 | BufPtr = NULL; 38 | stopProcess = 0; 39 | playCursor = 0; 40 | #endif 41 | pcmwf.wFormatTag = WAVE_FORMAT_PCM; 42 | pcmwf.nChannels = 2; 43 | pcmwf.nSamplesPerSec = (unsigned int)SAMPLE_RATE; 44 | pcmwf.wBitsPerSample = 16; 45 | pcmwf.nBlockAlign = (pcmwf.nChannels * pcmwf.wBitsPerSample) / 8; 46 | pcmwf.nAvgBytesPerSec = pcmwf.nSamplesPerSec * pcmwf.nBlockAlign; 47 | pcmwf.cbSize = 0; 48 | } 49 | 50 | void CController::FillBuffer(short *bShort, int size) 51 | { 52 | int tmp1; 53 | int tmp2; 54 | int iaux; 55 | int tambufferInt = SAMPLES_PER_PROCESS<<1; 56 | int tambufferExt = size<<1; 57 | 58 | while (1) 59 | { 60 | if (!posInt) 61 | { 62 | while (tuneReader.events[tunePointer].timestamp < (bufferPos + SAMPLES_PER_PROCESS) && tunePointer < NEVENTS) 63 | { 64 | synthesizer.SendEvent(tuneReader.events[tunePointer].status,tuneReader.events[tunePointer].data1,tuneReader.events[tunePointer].data2,tuneReader.events[tunePointer].timestamp); 65 | tunePointer++; 66 | } 67 | synthesizer.Process(synthesizer.buffers.bSynthOut, SAMPLES_PER_PROCESS, bufferPos); 68 | bufferPos += SAMPLES_PER_PROCESS; 69 | } 70 | tmp1 = tambufferInt-posInt; 71 | tmp2 = tambufferExt-posExt; 72 | iaux = tmp1= tambufferInt) 80 | { 81 | posInt = 0; 82 | } 83 | if (posExt >= tambufferExt) 84 | { 85 | posExt = 0; 86 | break; 87 | } 88 | } 89 | } 90 | 91 | #ifndef __RENDER_TO_MEMORY__ONLY__ 92 | void CController::RenderToFile(void) 93 | { 94 | FILE *file; 95 | short Buffer[BUFFER_SIZE_FILE<<1]; 96 | int Temp = 0; 97 | int filesize; 98 | 99 | memset(Buffer, 0, (BUFFER_SIZE_FILE<<1) * sizeof(short)); 100 | 101 | file = fopen(EXECUTABLE_NAME".wav", "wb"); 102 | fseek(file, 0, SEEK_SET); 103 | 104 | // file header 105 | fwrite("RIFF", 4, 1, file); 106 | fwrite(" ", 4, 1, file); // file size 107 | fwrite("WAVE", 4, 1, file); 108 | fwrite("fmt ", 4, 1, file); 109 | Temp = sizeof(WAVEFORMATEX); 110 | fwrite(&Temp , 4, 1, file); 111 | 112 | // wave format 113 | fwrite(&pcmwf, Temp, 1, file); 114 | 115 | // chunk header 116 | fwrite("data", 4, 1, file); 117 | fwrite(" ", 4, 1, file); // data size 118 | 119 | while (tunePointer < NEVENTS || synthesizer.GetState() == ACTIVE) 120 | { 121 | FillBuffer(Buffer, BUFFER_SIZE_FILE); 122 | fwrite(Buffer, (BUFFER_SIZE_FILE * pcmwf.nBlockAlign), 1, file); 123 | } 124 | 125 | fseek(file, 0, SEEK_END); 126 | filesize = ftell(file); 127 | 128 | fseek(file, 4, SEEK_SET); 129 | fwrite(&filesize, 4, 1, file); 130 | 131 | filesize -= 48; // minus header size 132 | fseek(file, 44, SEEK_SET); 133 | fwrite(&filesize, 4, 1, file); 134 | 135 | fclose(file); 136 | } 137 | #endif 138 | 139 | void CController::RenderToProfiling(void) 140 | { 141 | short Buffer[BUFFER_SIZE_FILE<<1]; 142 | 143 | memset(Buffer, 0, sizeof(Buffer)); 144 | 145 | while (tunePointer < NEVENTS || synthesizer.GetState() == ACTIVE) 146 | { 147 | FillBuffer(Buffer, BUFFER_SIZE_FILE); 148 | } 149 | } 150 | 151 | #ifdef __WITH_DSOUND__ 152 | void CController::RenderToSoundcard(void) 153 | { 154 | lplpDsb->Lock(previousPosition * BUFFER_SIZE_DS * pcmwf.nBlockAlign, BUFFER_SIZE_DS * pcmwf.nBlockAlign, &BufPtr, &BufBytes, NULL, NULL, 0); 155 | 156 | short *Buffer = (short*)BufPtr; 157 | 158 | FillBuffer(Buffer, BUFFER_SIZE_DS); 159 | 160 | lplpDsb->Unlock(BufPtr, BufBytes, NULL, 0); 161 | 162 | if (tunePointer >= NEVENTS && synthesizer.GetState() == INACTIVE) 163 | PostMessage(hWnd,WM_DESTROY,0,0); 164 | } 165 | 166 | DWORD WINAPI CController::Process(void* classe) 167 | { 168 | CController* pThis = (CController*)classe; 169 | 170 | ULONG size = BUFFER_SIZE_DS * pThis->pcmwf.nBlockAlign; 171 | 172 | while (1) 173 | { 174 | if (pThis->stopProcess) 175 | { 176 | pThis->stopProcess = 2; 177 | ExitThread(0); 178 | } 179 | 180 | pThis->lplpDsb->GetCurrentPosition(&pThis->playCursor, NULL); 181 | 182 | pThis->previousPosition = pThis->nextPosition; 183 | pThis->nextPosition = (char)(pThis->playCursor / size); 184 | if (pThis->nextPosition != pThis->previousPosition) 185 | pThis->RenderToSoundcard(); 186 | 187 | Sleep(5); 188 | } 189 | return 0; 190 | } 191 | 192 | void CController::Start(HWND hWnd) 193 | { 194 | this->hWnd = hWnd; 195 | HRESULT hr = 0; 196 | 197 | hr = DirectSoundCreate(NULL, &lpDS, NULL); 198 | if (hr != DS_OK) 199 | { 200 | printf("DirectSoundCreate error"); 201 | PostMessage(hWnd,WM_DESTROY,0,0); 202 | return; 203 | } 204 | 205 | hr = lpDS->SetCooperativeLevel(hWnd, DSSCL_PRIORITY); 206 | if (hr != DS_OK) 207 | { 208 | printf("SetCooperativeLevel error"); 209 | PostMessage(hWnd,WM_DESTROY,0,0); 210 | return; 211 | } 212 | 213 | memset(&dsbdesc, 0, sizeof(DSBUFFERDESC)); 214 | dsbdesc.dwSize = sizeof(DSBUFFERDESC); 215 | dsbdesc.dwFlags = DSBCAPS_LOCSOFTWARE | DSBCAPS_GLOBALFOCUS | DSBCAPS_GETCURRENTPOSITION2; 216 | dsbdesc.dwBufferBytes = NUM_BUFFERS * BUFFER_SIZE_DS * pcmwf.nBlockAlign; 217 | dsbdesc.lpwfxFormat = &pcmwf; 218 | 219 | hr = lpDS->CreateSoundBuffer(&dsbdesc, &lplpDsb, NULL); 220 | if (hr != DS_OK) 221 | { 222 | printf("CreateSoundBuffer error"); 223 | PostMessage(hWnd,WM_DESTROY,0,0); 224 | return; 225 | } 226 | 227 | // fill the entire buffer before to start playing 228 | previousPosition = 0; 229 | RenderToSoundcard(); 230 | previousPosition = 1; 231 | RenderToSoundcard(); 232 | previousPosition = 2; 233 | RenderToSoundcard(); 234 | previousPosition = 3; 235 | RenderToSoundcard(); 236 | previousPosition = 0; 237 | 238 | lplpDsb->SetCurrentPosition(0); 239 | lplpDsb->Play(0, 0, DSBPLAY_LOOPING); 240 | 241 | DWORD threadID; 242 | hthread = CreateThread(NULL, 0, Process, this, 0, &threadID); 243 | } 244 | 245 | void CController::Stop() 246 | { 247 | stopProcess = 1; 248 | 249 | while (stopProcess != 2); 250 | 251 | lplpDsb->Stop(); 252 | lplpDsb->Release(); 253 | lpDS->Release(); 254 | } 255 | #endif 256 | -------------------------------------------------------------------------------- /src/demo/controller.h: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "synthesizer.h" 20 | #include "tune.h" 21 | #include "tunereader.h" 22 | 23 | #ifdef __WITH_DSOUND__ 24 | #include 25 | #include 26 | #include 27 | #else 28 | typedef struct { 29 | unsigned short wFormatTag; 30 | unsigned short nChannels; 31 | unsigned int nSamplesPerSec; 32 | unsigned int nAvgBytesPerSec; 33 | unsigned short nBlockAlign; 34 | unsigned short wBitsPerSample; 35 | unsigned short cbSize; 36 | } WAVEFORMATEX; 37 | 38 | #define WAVE_FORMAT_PCM 1 39 | #endif 40 | 41 | #define NUM_BUFFERS 4 42 | #define BUFFER_SIZE_DS 32768 43 | #define BUFFER_SIZE_FILE 1024 44 | 45 | class CController 46 | { 47 | private: 48 | WAVEFORMATEX pcmwf; 49 | CSynthesizer synthesizer; 50 | CTuneReader tuneReader; 51 | char nextPosition; 52 | char previousPosition; 53 | unsigned int bufferPos; 54 | #ifdef __DSOUND_INCLUDED__ 55 | IDirectSound *lpDS; 56 | IDirectSoundBuffer *lplpDsb; 57 | DSBUFFERDESC dsbdesc; 58 | void *BufPtr; 59 | DWORD BufBytes; 60 | DWORD playCursor; 61 | volatile char stopProcess; 62 | HANDLE hthread; 63 | HWND hWnd; 64 | static DWORD WINAPI Process(void*); 65 | void RenderToSoundcard(void); 66 | #endif 67 | int tunePointer; 68 | int posExt; 69 | int posInt; 70 | void FillBuffer(short *bShort, int size); 71 | public: 72 | CController(); 73 | #ifndef __RENDER_TO_MEMORY__ONLY__ 74 | void RenderToFile(void); 75 | #endif 76 | void RenderToProfiling(void); 77 | #ifdef __DSOUND_INCLUDED__ 78 | void Start(HWND hWnd); 79 | void Stop(); 80 | #endif 81 | }; 82 | -------------------------------------------------------------------------------- /src/demo/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifdef __WITH_DSOUND__ 20 | #define WIN32_LEAN_AND_MEAN 21 | #include 22 | #endif 23 | #include "controller.h" 24 | #include 25 | #include 26 | #include "nonguitoolkit.h" 27 | 28 | int main(int argc, char* argv[]) 29 | { 30 | CController controller; 31 | printf(TITLE_FULL); 32 | printf("\n"); 33 | #ifdef __RENDER_TO_MEMORY__ONLY__ 34 | unsigned int time = GetTick(); 35 | controller.RenderToProfiling(); 36 | time = GetTick() - time; 37 | printf("Total time: %u\n", time); 38 | #else 39 | if (argc>1) 40 | { 41 | if (!strcmp(argv[1], "-f")) 42 | { 43 | printf("Writing the file...\n"); 44 | unsigned int time = GetTick(); 45 | controller.RenderToFile(); 46 | time = GetTick() - time; 47 | printf("Total time: %u\n", time); 48 | } 49 | else if (!strcmp(argv[1], "-m")) 50 | { 51 | printf("Rendering to memory...\n"); 52 | unsigned int time = GetTick(); 53 | controller.RenderToProfiling(); 54 | time = GetTick() - time; 55 | printf("Total time: %u\n", time); 56 | } 57 | else 58 | { 59 | printf("Invalid option.\n"); 60 | } 61 | #ifdef __DSOUND_INCLUDED__ 62 | } 63 | else 64 | { 65 | controller.Start(GetForegroundWindow()); 66 | printf("Press ESC to quit...\n"); 67 | while (GetAsyncKeyState(VK_ESCAPE)>=0) 68 | { 69 | static const char* anim[]={"|","/","-","\\"}; 70 | static char pos = 0; 71 | printf(anim[pos++&3]); 72 | printf("\r"); 73 | Sleep(100); 74 | } 75 | controller.Stop(); 76 | #else 77 | } 78 | else 79 | { 80 | printf("Usage:\n \"%s -f\" to render to a wav file\n \"%s -m\" to render to memory (to measure performance)\n", EXECUTABLE_NAME, EXECUTABLE_NAME); 81 | #endif 82 | } 83 | #endif 84 | return 0; 85 | } 86 | -------------------------------------------------------------------------------- /src/demo/tunereader.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "tune.h" 20 | #include "tunereader.h" 21 | 22 | CTuneReader::CTuneReader() 23 | { 24 | unsigned short division; 25 | unsigned short nchunks; 26 | unsigned int evcursor = 0; 27 | unsigned int currcoef; 28 | unsigned int i; 29 | unsigned int endpos; 30 | unsigned int len; 31 | EVENT auxev; 32 | tune_cursor = 0; 33 | read_bytes(&division, sizeof(short)); 34 | read_bytes(&nchunks, sizeof(short)); 35 | while (nchunks--) 36 | { 37 | /* Read chunk data */ 38 | read_bytes(&len, sizeof(int)); 39 | endpos = evcursor + len; 40 | for (i=evcursor;i pivot.timestamp && j > left) 108 | { 109 | j--; 110 | } 111 | if (i <= j) 112 | { 113 | tmp = events[i]; 114 | events[i] = events[j]; 115 | events[j] = tmp; 116 | i++; 117 | j--; 118 | } 119 | } 120 | if (j > left) 121 | { 122 | quick_sort(events, left, j); 123 | } 124 | if (i < right) 125 | { 126 | quick_sort(events, i, right); 127 | } 128 | } -------------------------------------------------------------------------------- /src/demo/tunereader.h: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #define SAMPLE_RATE 44100.f 20 | 21 | typedef struct 22 | { 23 | unsigned int timestamp; 24 | unsigned char status; 25 | unsigned char data1; 26 | unsigned char data2; 27 | } EVENT; 28 | 29 | 30 | class CTuneReader 31 | { 32 | private: 33 | unsigned int tune_cursor; 34 | void read_bytes(void *p, char size); 35 | static void quick_sort(EVENT* events, int left, int right); 36 | public: 37 | CTuneReader(); 38 | EVENT events[NEVENTS]; 39 | }; 40 | -------------------------------------------------------------------------------- /src/gui/button.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include 20 | #include 21 | #include "synthesizer.h" 22 | #include "control.h" 23 | #include "button.h" 24 | 25 | #define BUTTON_WIDTH 42 26 | #define BUTTON_HEIGHT 16 27 | 28 | CButton::CButton(int bmp, int index, CSynthesizer *synthesizer, char &channel, int type, int x, int y) 29 | { 30 | this->toolkit = NULL; 31 | this->index = index; 32 | this->bmp = bmp; 33 | this->synthesizer = synthesizer; 34 | this->channel = &channel; 35 | this->type = type; 36 | this->left = x; 37 | this->top = y; 38 | this->right = x + BUTTON_WIDTH; 39 | this->bottom = y + BUTTON_HEIGHT; 40 | } 41 | 42 | void CButton::OnClick(int x, int y) 43 | { 44 | // fires the assigned action 45 | switch (type) 46 | { 47 | case BT_MINUS_10: 48 | if (synthesizer->GetBankMode()) 49 | { 50 | int ultbank = synthesizer->GetBankCount() - 1; 51 | int numbank = synthesizer->GetBankIndex(); 52 | numbank -= 10; 53 | if (numbank < 0) 54 | numbank = 0; 55 | synthesizer->SetBankIndex(numbank); 56 | } 57 | else 58 | { 59 | unsigned char numprog; 60 | numprog = synthesizer->GetNumProgr(*channel); 61 | numprog -= 10; 62 | if (numprog > 127) 63 | numprog = 127; 64 | synthesizer->SendEvent(0xC0 + *channel, numprog, 0, 0); 65 | } 66 | break; 67 | case BT_MINUS_1: 68 | if (synthesizer->GetBankMode()) 69 | { 70 | int ultbank = synthesizer->GetBankCount() - 1; 71 | int numbank = synthesizer->GetBankIndex(); 72 | numbank = synthesizer->GetBankIndex(); 73 | numbank -= 1; 74 | if (numbank > ultbank) 75 | numbank = ultbank; 76 | if (numbank < 0) 77 | numbank = ultbank; 78 | synthesizer->SetBankIndex(numbank); 79 | } 80 | else 81 | { 82 | unsigned char numprog; 83 | numprog = synthesizer->GetNumProgr(*channel); 84 | numprog -= 1; 85 | if (numprog > 127) 86 | numprog = 127; 87 | synthesizer->SendEvent(0xC0 + *channel, numprog, 0, 0); 88 | } 89 | break; 90 | case BT_PLUS_1: 91 | if (synthesizer->GetBankMode()) 92 | { 93 | int ultbank = synthesizer->GetBankCount() - 1; 94 | int numbank = synthesizer->GetBankIndex(); 95 | numbank = synthesizer->GetBankIndex(); 96 | numbank += 1; 97 | if (numbank > ultbank) 98 | numbank = 0; 99 | synthesizer->SetBankIndex(numbank); 100 | } 101 | else 102 | { 103 | unsigned char numprog; 104 | numprog = synthesizer->GetNumProgr(*channel); 105 | numprog += 1; 106 | if (numprog > 127) 107 | numprog = 0; 108 | synthesizer->SendEvent(0xC0 + *channel, numprog, 0, 0); 109 | } 110 | break; 111 | case BT_PLUS_10: 112 | if (synthesizer->GetBankMode()) 113 | { 114 | int ultbank = synthesizer->GetBankCount() - 1; 115 | int numbank = synthesizer->GetBankIndex(); 116 | numbank = synthesizer->GetBankIndex(); 117 | numbank += 10; 118 | if (numbank > ultbank) 119 | numbank = ultbank; 120 | synthesizer->SetBankIndex(numbank); 121 | } 122 | else 123 | { 124 | unsigned char numprog; 125 | numprog = synthesizer->GetNumProgr(*channel); 126 | numprog += 10; 127 | if (numprog > 127) 128 | numprog = 0; 129 | synthesizer->SendEvent(0xC0 + *channel, numprog, 0, 0); 130 | } 131 | break; 132 | case BT_STORE: 133 | synthesizer->SetBankMode(false); 134 | synthesizer->StoreProgram(*channel); 135 | break; 136 | case BT_BANK: 137 | synthesizer->SetBankMode(true); 138 | break; 139 | case BT_PROGRAM: 140 | synthesizer->SetBankMode(false); 141 | synthesizer->SetStandBy(*channel, false); 142 | break; 143 | } 144 | } 145 | 146 | int CButton::GetCoordinates (oxeCoords *coords) 147 | { 148 | coords->destX = this->left; 149 | coords->destY = this->top; 150 | coords->width = this->right - this->left; 151 | coords->height = this->bottom - this->top; 152 | coords->origBmp = this->bmp; 153 | coords->origX = 0; 154 | coords->origY = index * BUTTON_HEIGHT; 155 | return 1; 156 | } 157 | 158 | void CButton::Repaint() 159 | { 160 | if (!toolkit) 161 | { 162 | return; 163 | } 164 | oxeCoords coords; 165 | GetCoordinates(&coords); 166 | toolkit->CopyRect(coords.destX, coords.destY, coords.width, coords.height, coords.origBmp, coords.origX, coords.origY); 167 | } 168 | 169 | bool CButton::GetName(char* str) 170 | { 171 | if (synthesizer->GetBankMode()) 172 | { 173 | strncpy(str, "SoundBank", TEXT_SIZE); 174 | } 175 | else if (synthesizer->GetStandBy(*channel)) 176 | { 177 | strncpy(str, "Store current", TEXT_SIZE); 178 | } 179 | else 180 | { 181 | snprintf(str, TEXT_SIZE, "Program %03i", synthesizer->GetNumProgr(*channel)); 182 | } 183 | return true; 184 | } 185 | 186 | int CButton::GetType() 187 | { 188 | return this->type; 189 | } 190 | -------------------------------------------------------------------------------- /src/gui/button.h: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | class CButton : public CControl 20 | { 21 | private: 22 | int type; // button type 23 | int index; 24 | void Repaint(); 25 | public: 26 | CButton(int bmp, int index, CSynthesizer *synthesizer, char &channel, int type, int x, int y); 27 | void OnClick(int x, int y); 28 | bool GetName(char* str); 29 | int GetType(void); 30 | int GetCoordinates(oxeCoords *coords); 31 | }; 32 | -------------------------------------------------------------------------------- /src/gui/channels.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include 20 | #include 21 | #include "synthesizer.h" 22 | #include "control.h" 23 | #include "channels.h" 24 | 25 | #define KEY_WIDTH 10 26 | #define KEY_HEIGHT 10 27 | 28 | CChannels::CChannels(int bmp, CSynthesizer *synthesizer, char &channel, int x, int y) 29 | { 30 | this->toolkit = NULL; 31 | this->bmp = bmp; 32 | this->channel = &channel; 33 | this->synthesizer = synthesizer; 34 | this->left = x; 35 | this->top = y; 36 | this->right = x + KEY_WIDTH * 8; 37 | this->bottom = y + KEY_HEIGHT * 2; 38 | } 39 | 40 | void CChannels::OnClick(int x, int y) 41 | { 42 | *channel = (char)((x - this->left) / KEY_WIDTH); 43 | if (y > this->top + KEY_HEIGHT) 44 | { 45 | *channel += 8; 46 | } 47 | Repaint(); 48 | } 49 | 50 | int CChannels::GetCoordinates (oxeCoords *coords) 51 | { 52 | char i; 53 | for (i=0;i< 8;i++) 54 | { 55 | coords->destX = this->left + i * KEY_WIDTH; 56 | coords->destY = this->top; 57 | coords->width = KEY_WIDTH; 58 | coords->height = KEY_HEIGHT; 59 | coords->origBmp = this->bmp; 60 | coords->origX = (*channel==i)?KEY_WIDTH:0; 61 | coords->origY = 0; 62 | coords++; 63 | } 64 | for (i=8;i<16;i++) 65 | { 66 | coords->destX = this->left + (i-8) * KEY_WIDTH; 67 | coords->destY = this->top + KEY_HEIGHT; 68 | coords->width = KEY_WIDTH; 69 | coords->height = KEY_HEIGHT; 70 | coords->origBmp = this->bmp; 71 | coords->origX = (*channel==i)?KEY_WIDTH:0; 72 | coords->origY = 0; 73 | coords++; 74 | } 75 | return MIDICHANNELS; 76 | } 77 | 78 | void CChannels::Repaint() 79 | { 80 | if (!toolkit) 81 | { 82 | return; 83 | } 84 | oxeCoords coords[MIDICHANNELS]; 85 | oxeCoords *c = coords; 86 | int count = GetCoordinates(c); 87 | while (count--) 88 | { 89 | toolkit->CopyRect(c->destX, c->destY, c->width, c->height, c->origBmp, c->origX, c->origY); 90 | c++; 91 | } 92 | } 93 | 94 | int CChannels::GetType() 95 | { 96 | return VL_CHANNELS; 97 | } 98 | 99 | bool CChannels::GetName(char* str) 100 | { 101 | snprintf(str, TEXT_SIZE, "Channel %02i", *channel + 1); 102 | return true; 103 | } 104 | -------------------------------------------------------------------------------- /src/gui/channels.h: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | class CChannels : public CControl 20 | { 21 | private: 22 | void Repaint(); 23 | public: 24 | CChannels(int bmp, CSynthesizer *synthesizer, char &channel, int x, int y); 25 | void OnClick(int x, int y); 26 | bool GetName(char* str); 27 | int GetType(void); 28 | int GetCoordinates(oxeCoords *coords); 29 | }; 30 | -------------------------------------------------------------------------------- /src/gui/control.h: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | typedef struct 20 | { 21 | int destX; 22 | int destY; 23 | int width; 24 | int height; 25 | int origBmp; 26 | int origX; 27 | int origY; 28 | } oxeCoords; 29 | 30 | class CControl 31 | { 32 | protected: 33 | int left; 34 | int top; 35 | int right; 36 | int bottom; 37 | char *channel; // MIDI channel 38 | int bmp; // image id 39 | CSynthesizer *synthesizer; // object to get/set the value 40 | CToolkit *toolkit; // graphical toolkit 41 | CHostInterface *hostinterface; 42 | virtual void Repaint () { } 43 | public: 44 | virtual void OnClick (int x, int y) { } 45 | virtual bool GetName (char* str) {return false;} 46 | virtual bool Update (void) {return false;} 47 | virtual bool IsKnob (void) {return false;} 48 | virtual bool IncreaseValue (int delta) {return false;} 49 | virtual int GetIndex (void) {return -1 ;} 50 | virtual int GetType (void) {return -1 ;} 51 | virtual int GetCoordinates (oxeCoords *coords) {return 0 ;} 52 | void SetToolkit(CToolkit *toolkit) 53 | { 54 | this->toolkit = toolkit; 55 | if (toolkit) 56 | { 57 | Repaint(); 58 | } 59 | } 60 | void SetHostInterface(CHostInterface *hostinterface) 61 | { 62 | this->hostinterface = hostinterface; 63 | } 64 | bool IsMouseOver(int x, int y) 65 | { 66 | return ((x >= left) && (x < right) && (y >= top) && (y < bottom)); 67 | } 68 | }; 69 | 70 | enum 71 | { 72 | VL_ZERO_TO_ONE, 73 | VL_MINUS1_2_PLUS1, 74 | VL_COARSE_TUNE, 75 | VL_FINE_TUNE, 76 | VL_TEMPO, 77 | VL_PORTAMENTO, 78 | VL_WAVEFORM, 79 | VL_FILTER, 80 | VL_MOD, 81 | VL_PAN, 82 | VL_PITCH_CURVE, 83 | VL_LFO_RATE, 84 | VL_LFO_DEST, 85 | VL_MOD_DEST, 86 | VL_ON_OFF, 87 | VL_CHANNELS, 88 | VL_FILTER_CUTOFF, 89 | BT_BANK, 90 | BT_PROGRAM, 91 | BT_MINUS_10, 92 | BT_MINUS_1, 93 | BT_PLUS_1, 94 | BT_PLUS_10, 95 | BT_NAME, 96 | BT_STORE 97 | }; 98 | -------------------------------------------------------------------------------- /src/gui/editor.h: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "synthesizer.h" 20 | #include "control.h" 21 | #include "lcd.h" 22 | #include "knob.h" 23 | #include "button.h" 24 | #include "key.h" 25 | #include "channels.h" 26 | 27 | #define COORDS_COUNT (LCD_COORDS + MIDICHANNELS + GUI_CONTROLS - 1) 28 | 29 | class CEditor 30 | { 31 | private: 32 | bool changingControl; 33 | int currentX; 34 | int currentY; 35 | int prevX; 36 | int prevY; 37 | CLcd *lcd; 38 | CControl *ctl[GUI_CONTROLS]; 39 | CSynthesizer *synthesizer; 40 | int cID; 41 | char channel; 42 | int TranslateNote(int cod); 43 | CToolkit *toolkit; 44 | CHostInterface *hostinterface; 45 | public: 46 | CEditor(CSynthesizer *synthesizer); 47 | ~CEditor(); 48 | void ProgramChanged(); 49 | void ProgramChangedWaiting(); 50 | void OnLButtonDblClick(int x, int y); 51 | void OnLButtonDown (int x, int y); 52 | void OnLButtonUp (); 53 | void OnRButtonDown (); 54 | bool OnChar (int cod); 55 | void OnMouseMove (int x, int y); 56 | void OnMouseWheel (int x, int y, int delta); 57 | void SetPar (int index, float value); 58 | float GetPar (int index); 59 | void GetParLabel (int index, char* label); 60 | void GetParDisplay (int index, char* text); 61 | void GetParName (int index, char* text); 62 | void Update (); 63 | void GetCoordinates (oxeCoords *coords); 64 | void SetToolkit (CToolkit *toolkit); 65 | void SetHostInterface (CHostInterface *hostinterface); 66 | }; 67 | -------------------------------------------------------------------------------- /src/gui/key.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include 20 | #include 21 | #include "synthesizer.h" 22 | #include "control.h" 23 | #include "key.h" 24 | 25 | CKey::CKey(int bmp, int index, int w, int h, const char *name, CSynthesizer *synthesizer, char &channel, int par, int x, int y) 26 | { 27 | strncpy(this->name, name, TEXT_SIZE); 28 | this->toolkit = NULL; 29 | this->bmp = bmp; 30 | this->index = index; 31 | this->w = w; 32 | this->h = h; 33 | this->channel = &channel; 34 | this->synthesizer = synthesizer; 35 | this->par = par; 36 | this->left = x; 37 | this->top = y; 38 | this->right = x + w; 39 | this->bottom = y + h; 40 | this->value = 0; 41 | } 42 | 43 | void CKey::OnClick(int x, int y) 44 | { 45 | this->value = !this->value; 46 | synthesizer->SetPar(*channel, par, this->value); 47 | Repaint(); 48 | } 49 | 50 | int CKey::GetCoordinates (oxeCoords *coords) 51 | { 52 | coords->destX = this->left; 53 | coords->destY = this->top; 54 | coords->width = this->right - this->left; 55 | coords->height = this->bottom - this->top; 56 | coords->origBmp = this->bmp; 57 | coords->origX = value ? this->w : 0; 58 | coords->origY = this->h * this->index; 59 | return 1; 60 | } 61 | 62 | void CKey::Repaint() 63 | { 64 | if (!toolkit) 65 | { 66 | return; 67 | } 68 | oxeCoords coords; 69 | GetCoordinates(&coords); 70 | toolkit->CopyRect(coords.destX, coords.destY, coords.width, coords.height, coords.origBmp, coords.origX, coords.origY); 71 | } 72 | 73 | bool CKey::Update(void) 74 | { 75 | if (this->value != (char)synthesizer->GetPar(*channel,par)) 76 | { 77 | this->value = !this->value; 78 | Repaint(); 79 | } 80 | return true; 81 | } 82 | 83 | bool CKey::GetName(char* str) 84 | { 85 | strncpy(str, name, TEXT_SIZE); 86 | return true; 87 | } 88 | 89 | int CKey::GetIndex() 90 | { 91 | return this->par; 92 | } 93 | 94 | int CKey::GetType() 95 | { 96 | return VL_ON_OFF; 97 | } 98 | -------------------------------------------------------------------------------- /src/gui/key.h: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | class CKey : public CControl 20 | { 21 | private: 22 | char value; // value 23 | char name[TEXT_SIZE]; // key name 24 | int w; // width in pixels 25 | int h; // height in pixels 26 | int par; // synth parameter assigned 27 | int index; // bitmap index in bitmap table 28 | void Repaint(); 29 | public: 30 | CKey(int bmp, int index, int w, int h, const char *name, CSynthesizer *synthesizer, char &channel, int par, int x, int y); 31 | void OnClick (int x, int y); 32 | bool Update (void); 33 | bool GetName (char* str); 34 | int GetIndex (void); 35 | int GetType (void); 36 | bool SetValue (char channel, char value); 37 | float GetValue (char channel); 38 | int GetCoordinates (oxeCoords *coords); 39 | }; 40 | -------------------------------------------------------------------------------- /src/gui/knob.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include "synthesizer.h" 24 | #include "control.h" 25 | #include "knob.h" 26 | #include "mapper.h" 27 | 28 | CKnob::CKnob(int bmp, int knobSize, const char *name, CSynthesizer *synthesizer, char &channel, int type, int par, int x, int y) 29 | { 30 | strncpy(this->name, name, TEXT_SIZE); 31 | this->toolkit = NULL; 32 | this->bmp = bmp; 33 | this->knobSize = knobSize; 34 | this->channel = &channel; 35 | this->synthesizer = synthesizer; 36 | this->par = par; 37 | this->type = type; 38 | this->left = x; 39 | this->top = y; 40 | this->right = x + knobSize; 41 | this->bottom = y + knobSize; 42 | this->value = 0; 43 | this->fvalue = 999.f; 44 | } 45 | 46 | int CKnob::GetCoordinates (oxeCoords *coords) 47 | { 48 | char valtemp = value; 49 | switch (type) 50 | { 51 | case VL_WAVEFORM: 52 | valtemp = (char)lrintf(fvalue*(MAXPARVALUE/(WAVEFORMS-1))); 53 | break; 54 | case VL_FILTER: 55 | valtemp = (char)lrintf(fvalue*(MAXPARVALUE/2)); 56 | break; 57 | case VL_LFO_DEST: 58 | valtemp = (char)lrintf(fvalue*(MAXPARVALUE/2)); 59 | break; 60 | case VL_MOD_DEST: 61 | valtemp = (char)lrintf(fvalue*(MAXPARVALUE/6)); 62 | break; 63 | } 64 | if (valtemp > 99) 65 | valtemp = 99; 66 | coords->destX = this->left; 67 | coords->destY = this->top; 68 | coords->width = this->right - this->left; 69 | coords->height = this->bottom - this->top; 70 | coords->origBmp = this->bmp; 71 | coords->origX = (valtemp - (abs(valtemp/10) * 10)) * this->knobSize; 72 | coords->origY = abs(valtemp/10) * this->knobSize; 73 | return 1; 74 | } 75 | 76 | void CKnob::Repaint() 77 | { 78 | if (!toolkit) 79 | { 80 | return; 81 | } 82 | oxeCoords coords; 83 | GetCoordinates(&coords); 84 | toolkit->CopyRect(coords.destX, coords.destY, coords.width, coords.height, coords.origBmp, coords.origX, coords.origY); 85 | } 86 | 87 | bool CKnob::Update(void) 88 | { 89 | float newValue = synthesizer->GetPar(*channel, par); 90 | if (newValue != this->fvalue) 91 | { 92 | this->fvalue = newValue; 93 | this->value = CMapper::FloatValueToIntValue(this->synthesizer, *channel, this->par, this->type, this->fvalue); 94 | Repaint(); 95 | } 96 | return true; 97 | } 98 | 99 | bool CKnob::IncreaseValue(int delta) 100 | { 101 | this->value += delta; 102 | if (this->value > (char)MAXPARVALUE) 103 | { 104 | this->value = (char)MAXPARVALUE; 105 | } 106 | if (this->value < 0) 107 | { 108 | this->value = 0; 109 | } 110 | this->fvalue = CMapper::IntValueToFloatValue(this->synthesizer, *channel, this->par, this->type, this->value); 111 | synthesizer->SetPar(*channel, this->par, this->fvalue); 112 | Repaint(); 113 | return true; 114 | } 115 | 116 | bool CKnob::GetName(char* str) 117 | { 118 | strncpy(str, name, TEXT_SIZE); 119 | return true; 120 | } 121 | 122 | int CKnob::GetIndex() 123 | { 124 | return this->par; 125 | } 126 | 127 | int CKnob::GetType() 128 | { 129 | return this->type; 130 | } 131 | -------------------------------------------------------------------------------- /src/gui/knob.h: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | class CKnob : public CControl 20 | { 21 | private: 22 | signed char value; // integer value 23 | float fvalue; // float value 24 | char name[TEXT_SIZE]; // knob name 25 | int knobSize; // size in pixels 26 | int par; // synth parameter assigned 27 | int type; // control type 28 | void Repaint(); 29 | public: 30 | CKnob(int bmp, int knobSize, const char *name, CSynthesizer *synthesizer, char &channel, int type, int par, int x, int y); 31 | bool Update (void); 32 | bool GetName (char* str); 33 | bool IsKnob() {return true;} 34 | bool IncreaseValue (int delta); 35 | int GetIndex (void); 36 | int GetType (void); 37 | float GetValue (char channel); 38 | int GetCoordinates (oxeCoords *coords); 39 | }; 40 | -------------------------------------------------------------------------------- /src/gui/lcd.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include 20 | #include "synthesizer.h" 21 | #include "control.h" 22 | #include "lcd.h" 23 | 24 | #define LCD_SEP_H 1 // horizontal space between the LCD characters 25 | #define LCD_SEP_V 1 // vertical space between the LCD characters 26 | #define LCD_CHAR_H 7 // char height in pixels 27 | #define LCD_CHAR_W 5 // char width in pixels 28 | #define LCD_X 0 // bg left 29 | #define LCD_Y 0 // bg top 30 | 31 | CLcd::CLcd(int bmp, int x, int y) 32 | { 33 | int i; 34 | for (i=0;ilcdx = x; 39 | this->lcdy = y; 40 | this->bmp = bmp; 41 | this->left = x + LCD_X; 42 | this->top = y + LCD_Y; 43 | this->right = this->left + (LCD_CHAR_W * LCD_COLS ) + (LCD_SEP_H * LCD_COLS ); 44 | this->bottom = this->top + (LCD_CHAR_H * LCD_LINES) + (LCD_SEP_V * LCD_LINES); 45 | this->toolkit = NULL; 46 | } 47 | 48 | int CLcd::GetCoordinates (oxeCoords *coords) 49 | { 50 | int i; 51 | for (i=0;idestX = lcdx + LCD_X + LCD_SEP_H + ((LCD_SEP_H + LCD_CHAR_W) * i); 54 | coords->destY = lcdy + LCD_Y + LCD_SEP_V; 55 | coords->width = LCD_CHAR_W; 56 | coords->height = LCD_CHAR_H; 57 | coords->origBmp = this->bmp; 58 | coords->origX = (0xF & (text0[i] - ' ')) * LCD_CHAR_W; 59 | coords->origY = ((0xF0 & (text0[i] - ' ')) / 0x10) * LCD_CHAR_H; 60 | coords++; 61 | } 62 | for (i=0;idestX = lcdx + LCD_X + LCD_SEP_H + ((LCD_SEP_H + LCD_CHAR_W) * i); 65 | coords->destY = lcdy + LCD_Y + LCD_SEP_V + LCD_CHAR_H + LCD_SEP_V; 66 | coords->width = LCD_CHAR_W; 67 | coords->height = LCD_CHAR_H; 68 | coords->origBmp = this->bmp; 69 | coords->origX = (0xF & (text1[i] - ' ')) * LCD_CHAR_W; 70 | coords->origY = ((0xF0 & (text1[i] - ' ')) / 0x10) * LCD_CHAR_H; 71 | coords++; 72 | } 73 | return LCD_COORDS; 74 | } 75 | 76 | void CLcd::Repaint() 77 | { 78 | if (!toolkit) 79 | { 80 | return; 81 | } 82 | oxeCoords coords[LCD_COLS * LCD_LINES]; 83 | oxeCoords *c = coords; 84 | int count = GetCoordinates(c); 85 | while (count--) 86 | { 87 | toolkit->CopyRect(c->destX, c->destY, c->width, c->height, c->origBmp, c->origX, c->origY); 88 | c++; 89 | } 90 | } 91 | 92 | bool CLcd::SetText(char lineIndex, const char* text) 93 | { 94 | int i = 0; 95 | int tam = strlen(text); 96 | if (lineIndex == 0) 97 | { 98 | if (tam >= LCD_COLS) 99 | { 100 | memcpy(text0,text,LCD_COLS); 101 | } 102 | else if (tam < LCD_COLS) 103 | { 104 | memcpy(text0,text,tam); 105 | for (i=tam;i= LCD_COLS) 113 | { 114 | memcpy(text1,text,LCD_COLS); 115 | } 116 | else if (tam < LCD_COLS) 117 | { 118 | memcpy(text1,text,tam); 119 | for (i=tam;i 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #define LCD_COLS 16 // columns 20 | #define LCD_LINES 2 // lines 21 | #define LCD_COORDS (LCD_COLS * LCD_LINES) 22 | 23 | class CLcd : public CControl 24 | { 25 | private: 26 | char text0[LCD_COLS]; 27 | char text1[LCD_COLS]; 28 | int lcdx; 29 | int lcdy; 30 | void Repaint(); 31 | public: 32 | CLcd(int bmpchars, int x, int y); 33 | bool SetText(char lineIndex, const char *text); 34 | int GetCoordinates(oxeCoords *coords); 35 | }; 36 | -------------------------------------------------------------------------------- /src/gui/mapper.h: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | class CMapper 20 | { 21 | public: 22 | static char FloatValueToIntValue(CSynthesizer *synthesizer, char channel, int par, int type, float fvalue); 23 | static float IntValueToFloatValue(CSynthesizer *synthesizer, char channel, int par, int type, char value ); 24 | static void GetDisplayValue (CSynthesizer *synthesizer, char channel, int par, int type, char* str ); 25 | }; 26 | -------------------------------------------------------------------------------- /src/macosx/app/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleName 6 | oxefmsynth 7 | CFBundleDisplayName 8 | oxefmsynth 9 | CFBundleIdentifier 10 | com.oxesoft.oxefmsynth 11 | CFBundleVersion 12 | 1.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleSignature 16 | OXFM 17 | CFBundleExecutable 18 | oxefmsynth 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/macosx/app/PkgInfo: -------------------------------------------------------------------------------- 1 | APPLOXFM -------------------------------------------------------------------------------- /src/macosx/vst/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleName 6 | oxefmsynth 7 | CFBundleDisplayName 8 | oxefmsynth 9 | CFBundleIdentifier 10 | com.oxesoft.oxefmsynth 11 | CFBundleVersion 12 | 1.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleSignature 16 | OXFM 17 | CFBundleExecutable 18 | oxefmsynth 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/macosx/vst/PkgInfo: -------------------------------------------------------------------------------- 1 | BNDLOXFM -------------------------------------------------------------------------------- /src/standalone/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "editor.h" 20 | #include "ostoolkit.h" 21 | #include "nonguitoolkit.h" 22 | #include 23 | 24 | #ifdef _WIN32 25 | void* hInstance; 26 | #endif 27 | 28 | int main(void) 29 | { 30 | #ifdef _WIN32 31 | hInstance = GetModuleHandle(NULL); 32 | #endif 33 | CSynthesizer s; 34 | CEditor e(&s); 35 | COSToolkit t(0, &e); 36 | unsigned int time = GetTick(); 37 | e.SetToolkit(&t); 38 | time = GetTick() - time; 39 | printf("full blitting time: %ums\n", time); 40 | t.StartWindowProcesses(); 41 | return t.WaitWindowClosed(); 42 | } 43 | -------------------------------------------------------------------------------- /src/synth/bank0.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/src/synth/bank0.bin -------------------------------------------------------------------------------- /src/synth/bank1.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/src/synth/bank1.bin -------------------------------------------------------------------------------- /src/synth/buffers.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "constants.h" 20 | #include "buffers.h" 21 | #include 22 | #include 23 | 24 | CBuffers::CBuffers() 25 | { 26 | memset(bOPA, 0,sizeof(bOPA)); 27 | memset(bOPB, 0,sizeof(bOPB)); 28 | memset(bOPC, 0,sizeof(bOPC)); 29 | memset(bOPD, 0,sizeof(bOPD)); 30 | memset(bOPE, 0,sizeof(bOPE)); 31 | memset(bOPF, 0,sizeof(bOPF)); 32 | memset(bOPX, 0,sizeof(bOPX)); 33 | memset(bOPZ, 0,sizeof(bOPZ)); 34 | memset(bREV, 0,sizeof(bREV)); 35 | memset(bDLY, 0,sizeof(bDLY)); 36 | memset(bNoteOut, 0,sizeof(bNoteOut)); 37 | for (int i=0;i max) 134 | max = aux; 135 | } 136 | // calculates the multiplication factor 137 | aux = 32767.0/max; 138 | // normalizes the signal 139 | for (i=0;i 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | class CBuffers 20 | { 21 | private: 22 | void FillWaveforms(); 23 | void Filtrar(int indorigem, int inddestino); 24 | void Normalizar(int indice); 25 | public: 26 | int bOPA [SAMPLES_PER_PROCESS]; 27 | int bOPB [SAMPLES_PER_PROCESS]; 28 | int bOPC [SAMPLES_PER_PROCESS]; 29 | int bOPD [SAMPLES_PER_PROCESS]; 30 | int bOPE [SAMPLES_PER_PROCESS]; 31 | int bOPF [SAMPLES_PER_PROCESS]; 32 | int bOPX [SAMPLES_PER_PROCESS]; 33 | int bOPZ [SAMPLES_PER_PROCESS]; 34 | int bREV [SAMPLES_PER_PROCESS]; 35 | int bDLY [SAMPLES_PER_PROCESS]; 36 | // output 37 | int bNoteOut [SAMPLES_PER_PROCESS<<1]; 38 | int bSynthOut [SAMPLES_PER_PROCESS<<1]; 39 | // waveforms 40 | short bWaves [WAVEFORMS][WAVEFORM_BSIZE]; 41 | // construtor 42 | CBuffers(); 43 | }; 44 | -------------------------------------------------------------------------------- /src/synth/constants.h: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | // ------------------------------------------------------------------ 20 | // configuration constants 21 | // ------------------------------------------------------------------ 22 | 23 | #define OXFM_MAJOR_VERSION 1 24 | #define OXFM_MINOR_VERSION 3 25 | #define OXFM_PATCH_VERSION 5 26 | #define VERSION_STR "1.3.6" 27 | #define VERSION_INT ((OXFM_MAJOR_VERSION * 100) + (OXFM_MINOR_VERSION * 10) + OXFM_PATCH_VERSION) 28 | #define TITLE_SMALL "Oxe FM Synth " VERSION_STR 29 | #define TITLE_FULL TITLE_SMALL " :: http://www.oxesoft.com" 30 | #define SAMPLES_PER_PROCESS 128 // the synth process buffer size 31 | #define WAVEFORM_BIT_DEPTH 11 32 | #define WAVEFORM_BSIZE (1< 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "constants.h" 20 | #include "oscillator.h" 21 | #include "buffers.h" 22 | #include "delay.h" 23 | #include 24 | #include 25 | 26 | /////////////////////////////////// 27 | //#define WITH_LINEAR_INTERPOLATION 28 | /////////////////////////////////// 29 | 30 | void CDelay::Init(short *b) 31 | { 32 | ti = 0.f; 33 | fe = 0.f; 34 | lf = 0.f; 35 | la = 0.f; 36 | idelay = 0; 37 | memset(bdelay,0,sizeof(bdelay)); 38 | osc.SetBuffer(BWAVE,b); 39 | } 40 | 41 | void CDelay::SetPar(char param, float value) 42 | { 43 | switch (param) 44 | { 45 | case SAMPLERATE: 46 | osc.SetPar(SAMPLERATE, value); 47 | break; 48 | case TIME: 49 | ti = value; 50 | break; 51 | case FEEDBACK: 52 | fe = value; 53 | break; 54 | case RATE: 55 | lf = value; 56 | break; 57 | case AMOUNT: 58 | la = value; 59 | break; 60 | } 61 | } 62 | 63 | void CDelay::Process(int *b, int size) 64 | { 65 | float lfo; 66 | int tempo; 67 | int passo; 68 | unsigned short tmp; 69 | // sets the LFO that acts about the delay time 70 | lfo = 1.f; 71 | if (lf) 72 | { 73 | osc.SetPar(FREQUENCY, lf * (float)size); 74 | lfo -= ((osc.Process() + 1.f)/2.f) * la * 0.25f; 75 | } 76 | // sets the time delay 77 | tempo = lrintf(ti * 65535.f * 32768.f * lfo); 78 | // actual process 79 | if (fe && ((!lf) || (!la))) 80 | { 81 | int feedb = lrintf(fe * 32768.f); 82 | tempo = tempo>>15; 83 | for (int i=0;i>15; 94 | for (int i=0;i>15); 110 | bdelay[idelay] = b[i] + ((bdelay[tmp] * feedb)/32768); 111 | #ifdef WITH_LINEAR_INTERPOLATION 112 | b[i] = bdelay[tmp] + (((bdelay[(tmp+1) & 0xFFFF] - bdelay[tmp]) * (65536 - ((int)tempoant & 0xFFFF)))>>16); 113 | #else 114 | b[i] = bdelay[tmp]; 115 | #endif 116 | idelay++; 117 | } 118 | } 119 | else if (!fe && lf && la) 120 | { 121 | passo = (tempo - tempoant) / size; 122 | for (int i=0;i>15); 126 | bdelay[idelay] = b[i]; 127 | #ifdef WITH_LINEAR_INTERPOLATION 128 | b[i] = bdelay[tmp] + (((bdelay[(tmp+1) & 0xFFFF] - bdelay[tmp]) * (65536 - ((int)tempoant & 0xFFFF)))>>16); 129 | #else 130 | b[i] = bdelay[tmp]; 131 | #endif 132 | idelay++; 133 | } 134 | } 135 | tempoant = tempo; 136 | } 137 | -------------------------------------------------------------------------------- /src/synth/delay.h: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | class CDelay 20 | { 21 | private: 22 | float ti; // time 23 | float fe; // feedback 24 | float lf; // LFO rate 25 | float la; // LFO amount 26 | // 1.486 seconds buffer 27 | int bdelay[0x10000]; 28 | // LFO 29 | COscillator osc; 30 | // buffer iterator 31 | unsigned short idelay; // here is the trick 32 | // auxiliar 33 | int tempoant; 34 | public: 35 | void Init(short *b); 36 | void Process(int *b, int size); 37 | void SetPar(char param, float value); 38 | }; 39 | -------------------------------------------------------------------------------- /src/synth/envelop.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "constants.h" 20 | #include "envelop.h" 21 | #include 22 | 23 | /* 24 | It need to be done to keep previous compatibility. 25 | The original version of this code (before to be public) made an envelop 26 | interpolation that limited each state to 32 samples, causing a side 27 | effect where the value choosen is smaller than the actual time calculated. 28 | If we remove this, the times will respect the program values from 29 | 0.000075 seconds (3 samples), changing the sounds of the original programs. 30 | */ 31 | #define KEEP_OLD_BEHAVIOUR if (!ss && counter < 32) counter = 32; 32 | 33 | void CEnvelop::Init() 34 | { 35 | sr = 0.f; 36 | es = INACTIVE; 37 | counter = 0; 38 | coef = 0; 39 | sa = 0; 40 | dl = 0.f; 41 | at = 0.f; 42 | de = 0.f; 43 | st = 0.f; 44 | su = 0.f; 45 | re = 0.f; 46 | ss = 0.f; 47 | } 48 | 49 | void CEnvelop::SetPar(char param, float value) 50 | { 51 | switch (param) 52 | { 53 | case SAMPLERATE: 54 | sr = value; 55 | break; 56 | case DELAY: 57 | dl = value; 58 | break; 59 | case ATTACK: 60 | at = value; 61 | break; 62 | case DECAY: 63 | de = value; 64 | break; 65 | case SUSTAIN: 66 | su = value; 67 | break; 68 | case SUSTAINTIME: 69 | st = value; 70 | break; 71 | case RELEASE: 72 | re = value; 73 | break; 74 | case SINGLESAMPLEMODE: 75 | ss = value; 76 | break; 77 | } 78 | } 79 | 80 | void CEnvelop::SendEvent(char event, int remainingSamples) 81 | { 82 | switch (event) 83 | { 84 | case NOTEON: 85 | if (dl) 86 | es = DELAY; 87 | else if (at) 88 | es = ATTACK; 89 | else if (de) 90 | es = DECAY; 91 | else if (su) 92 | es = SUSTAIN; 93 | else 94 | es = ENDED; 95 | break; 96 | case NOTEOFF: 97 | counter = remainingSamples; 98 | if (re) 99 | es = RELEASE; 100 | else 101 | es = ENDED; 102 | break; 103 | } 104 | } 105 | 106 | int CEnvelop::CalcCoef() 107 | { 108 | if (counter) 109 | return counter; 110 | switch (es) 111 | { 112 | case DELAY: 113 | counter = lrintf(dl * sr); 114 | KEEP_OLD_BEHAVIOUR 115 | coef = 0; 116 | if (at) 117 | es = ATTACK; 118 | else if (de) 119 | es = DECAY; 120 | else if (su) 121 | es = SUSTAIN; 122 | else 123 | es = ENDED; 124 | break; 125 | case ATTACK: 126 | counter = lrintf(at * sr); 127 | KEEP_OLD_BEHAVIOUR 128 | if (counter < 1) 129 | { 130 | counter = 1; 131 | } 132 | coef = MAXINT / counter; 133 | if (de) 134 | es = DECAY; 135 | else if (su) 136 | es = SUSTAIN; 137 | else 138 | es = ENDED; 139 | break; 140 | case DECAY: 141 | counter = lrintf(de * sr); 142 | KEEP_OLD_BEHAVIOUR 143 | if (counter < 1) 144 | { 145 | counter = 1; 146 | } 147 | coef = lrintf((-1.f + su) / counter * FMAXINT); 148 | sa = MAXINT; 149 | if (su) 150 | es = SUSTAIN; 151 | else 152 | es = RELEASE; 153 | break; 154 | case SUSTAIN: 155 | if (st) 156 | { 157 | counter = lrintf(st * sr); 158 | KEEP_OLD_BEHAVIOUR 159 | if (counter < 1) 160 | { 161 | counter = 1; 162 | } 163 | coef = lrintf(-su / counter * FMAXINT); 164 | es = RELEASE; 165 | } 166 | else 167 | { 168 | counter = MAXINT; 169 | coef = 0; 170 | } 171 | sa = lrintf(su*FMAXINT); 172 | break; 173 | case RELEASE: 174 | counter = lrintf(re * sr); 175 | KEEP_OLD_BEHAVIOUR 176 | if (counter < 1) 177 | { 178 | counter = 1; 179 | } 180 | coef = -sa / counter; 181 | es = ENDED; 182 | break; 183 | case ENDED: 184 | es = INACTIVE; 185 | counter = MAXINT; 186 | coef = 0; 187 | sa = 0; 188 | break; 189 | } 190 | return counter; 191 | } 192 | 193 | float CEnvelop::Process() 194 | { 195 | if (!counter) 196 | CalcCoef(); 197 | counter--; 198 | sa += coef; 199 | float temp = float(sa>>16); 200 | temp /= 32768.f ; 201 | temp *= temp ; 202 | return temp ; 203 | } 204 | 205 | char CEnvelop::GetState() 206 | { 207 | return es; 208 | } 209 | 210 | void CEnvelop::Process(int *b, int size, int offset, float volume) 211 | { 212 | int temp; 213 | int vol = lrintf(volume * 127.f); 214 | while (counter <= size - offset) 215 | { 216 | for (int i = offset; i < offset + counter; i++) 217 | { 218 | sa += coef ; 219 | temp = sa>>16 ; 220 | temp = (temp*temp)>>15; 221 | b[i] = (b[i] * vol)>>7; 222 | b[i] = (temp*b[i])>>15; 223 | } 224 | offset += counter; 225 | counter = 0; 226 | CalcCoef(); 227 | } 228 | for (int i = offset; i < size; i++) 229 | { 230 | sa += coef ; 231 | temp = sa>>16 ; 232 | temp = (temp*temp)>>15; 233 | b[i] = (b[i] * vol)>>7; 234 | b[i] = (temp*b[i])>>15; 235 | } 236 | counter -= size - offset; 237 | } 238 | -------------------------------------------------------------------------------- /src/synth/envelop.h: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #define FMAXINT 2147483647.f // = 0x7FFFFFFF 20 | #ifndef MAXINT 21 | #define MAXINT 0x7FFFFFFF 22 | #endif 23 | 24 | class CEnvelop 25 | { 26 | private: 27 | float sr; 28 | char es; // envelop state 29 | int counter; // to the next state 30 | int coef; // coeficient 31 | int sa; // output signal 32 | float dl; // delay time 33 | float at; // attack time 34 | float de; // decay time 35 | float su; // sustain level 36 | float st; // sustein time 37 | float re; // release time 38 | float ss; // single sample mode 39 | int CalcCoef(); 40 | public: 41 | void Init(); 42 | float Process(); // single sample mode 43 | void SendEvent(char event, int remainingSamples); 44 | char GetState(void); 45 | void SetPar(char param, float value); 46 | void Process(int *b, int size, int offset, float volume); 47 | }; 48 | -------------------------------------------------------------------------------- /src/synth/filter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "constants.h" 20 | #include "filter.h" 21 | #include 22 | 23 | void CFilter::Init() 24 | { 25 | sr = 0.f; 26 | tf = 0; 27 | fr = 0.f; 28 | fr1 =-1.f; 29 | re = 0.f; 30 | re1 =-1.f; 31 | en = 1.f; 32 | b0a0 = 0; 33 | b1a0 = 0; 34 | b2a0 = 0; 35 | a1a0 = 0; 36 | a2a0 = 0; 37 | ou1 = 0; 38 | ou2 = 0; 39 | in1 = 0; 40 | in2 = 0; 41 | } 42 | 43 | void CFilter::SetPar(char param, float value) 44 | { 45 | switch (param) 46 | { 47 | case SAMPLERATE: 48 | sr = value; 49 | break; 50 | case ENVELOP: 51 | en = powf(2.f,value)-1.f; 52 | break; 53 | case TYPE: 54 | tf = (char)lrintf(value); 55 | break; 56 | case FREQUENCY: 57 | fr = value; 58 | break; 59 | case RESONANCE: 60 | re = value; if (re < 0.001f) re = 0.001f; 61 | break; 62 | } 63 | // Initializes coefficients 64 | CalcCoef(tf,fr*en,re); 65 | } 66 | 67 | void CFilter::Process(int *b, int size, int offset) 68 | { 69 | float in0; 70 | float ou0; 71 | for (int i=offset;i2) 99 | { 100 | b0=(1.0-tcos)/2.0; 101 | b1=1.0-tcos; 102 | b2=b0; 103 | a0=1.0+alpha; 104 | a1=-2.0*tcos; 105 | a2=1.0-alpha; 106 | } 107 | 108 | // hipass 109 | if(type==1) 110 | { 111 | b0=(1.0+tcos)/2.0; 112 | b1=-(1.0+tcos); 113 | b2=b0; 114 | a0=1.0+alpha; 115 | a1=-2.0*tcos; 116 | a2=1.0-alpha; 117 | } 118 | 119 | // bandpass csg 120 | if(type==2) 121 | { 122 | b0=tsin/2.0; 123 | b1=0.0; 124 | b2=-b0; 125 | a0=1.0+alpha; 126 | a1=-2.0*tcos; 127 | a2=1.0-alpha; 128 | } 129 | 130 | // set filter coeffs 131 | b0a0=float(b0/a0); 132 | b1a0=float(b1/a0); 133 | b2a0=float(b2/a0); 134 | a1a0=float(a1/a0); 135 | a2a0=float(a2/a0); 136 | } 137 | -------------------------------------------------------------------------------- /src/synth/filter.h: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | class CFilter 20 | { 21 | private: 22 | float sr; 23 | char tf; // filter type 24 | float fr; // central frequency 25 | float fr1; // previous central frenquecy 26 | float re; // resonance 27 | float re1; // previous resonance 28 | float en; // envelop 29 | // coeficients 30 | float b0a0; 31 | float b1a0; 32 | float b2a0; 33 | float a1a0; 34 | float a2a0; 35 | // in/out history 36 | float ou1; 37 | float ou2; 38 | float in1; 39 | float in2; 40 | void CalcCoef(int const type, double const frequencia, double const q); 41 | public: 42 | void Init(); 43 | void Process(int *b, int size, int offset); 44 | void SetPar(char param, float value); 45 | }; 46 | -------------------------------------------------------------------------------- /src/synth/noise.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "constants.h" 20 | #include "noise.h" 21 | #include 22 | 23 | void CNoise::Init() 24 | { 25 | sr = 0.f; 26 | fr = 0.f; 27 | fr1 =-1.f; 28 | re = 0.f; 29 | re1 =-1.f; 30 | am = 128; 31 | bp = 0; 32 | b0a0 = 0; 33 | b2a0 = 0; 34 | a1a0 = 0; 35 | a2a0 = 0; 36 | ou1 = 0; 37 | ou2 = 0; 38 | in1 = 0; 39 | in2 = 0; 40 | } 41 | 42 | void CNoise::SetPar(char param, float value) 43 | { 44 | switch (param) 45 | { 46 | case SAMPLERATE: 47 | sr = value; 48 | break; 49 | case FREQUENCY: 50 | fr = value; 51 | break; 52 | case RESONANCE: 53 | re = value; 54 | break; 55 | case VOLUME: 56 | am = lrintf(value * 128.f); 57 | break; 58 | case BYPASS: 59 | bp = lrintf(value); 60 | break; 61 | } 62 | // initializes coefficients 63 | CalcCoef(fr,re); 64 | } 65 | 66 | void CNoise::Process(int *b, int size, int offset) 67 | { 68 | short in0; 69 | int ou0; 70 | int i; 71 | // bypasses the signal if the key is on 72 | if (!bp) 73 | { 74 | for (i=offset;i 4096) 78 | b[i]= 4096; 79 | if (b[i]<-4096) 80 | b[i]=-4096; 81 | b[i]<<=3; 82 | } 83 | } 84 | // generates noise if there is volume 85 | if (am) 86 | { 87 | // recalc coeffs if they have changed 88 | if (fr1 != fr || re1 != re) 89 | { 90 | CalcCoef(fr,re); 91 | fr1 = fr; 92 | re1 = re; 93 | } 94 | for (i=offset;i>16); 101 | ou0 = ((b0a0*in0)>>15) + ((b2a0*in2)>>15) - ((a1a0*ou1)>>15) - ((a2a0*ou2)>>15); 102 | in2 = in1; 103 | in1 = in0; 104 | ou2 = ou1; 105 | ou1 = ou0; 106 | b[i]+= (ou0*am)>>7; 107 | } 108 | } 109 | } 110 | 111 | void CNoise::CalcCoef(double const frequencia,double const q) 112 | { 113 | double a0; 114 | double a1; 115 | double a2; 116 | double b0; 117 | double b2; 118 | double freq = frequencia; if (freq <= C0) freq = C0; 119 | double const omega = 2.0*D_PI*freq/sr; 120 | double const tsin = sin(omega); 121 | double const tcos = cos(omega); 122 | double const alpha = tsin/(2.0*q); 123 | 124 | // bandpass czpg 125 | b0=tsin/2.0; 126 | b2=-b0; 127 | a0=1.0+alpha; 128 | a1=-2.0*tcos; 129 | a2=1.0-alpha; 130 | 131 | // set filter coeffs 132 | b0a0=lrintf(float((b0/a0)*32768.0)); 133 | b2a0=lrintf(float((b2/a0)*32768.0)); 134 | a1a0=lrintf(float((a1/a0)*32768.0)); 135 | a2a0=lrintf(float((a2/a0)*32768.0)); 136 | } 137 | -------------------------------------------------------------------------------- /src/synth/noise.h: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | class CNoise 20 | { 21 | private: 22 | float sr; 23 | float fr; // central frequency 24 | float fr1; // previous central frequency 25 | float re; // resonance 26 | float re1; // previous resonance 27 | // coeficients 28 | int b0a0; 29 | int b2a0; 30 | int a1a0; 31 | int a2a0; 32 | // in/out history 33 | int ou1; 34 | int ou2; 35 | int in1; 36 | int in2; 37 | // noise volume 38 | int am; 39 | int bp; 40 | // calculates the filter coefs 41 | void CalcCoef(double const frequencia, double const q); 42 | public: 43 | void Init(); 44 | void Process(int *b, int size, int offset); 45 | void SetPar(char param, float value); 46 | }; 47 | -------------------------------------------------------------------------------- /src/synth/note.h: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | class CNote 20 | { 21 | private: 22 | float samplerate; 23 | SProgram *program; // the note's program 24 | CBuffers *buffers; // the buffers 25 | float ptc; // pitch weel (1.f == inert) 26 | float aft; // aftertouch (0.f a 1.f) 27 | float lfodph; // from MODULATION 28 | char state; // (on/off) the note state is defined by the operators's envelops except the Z one 29 | // portamento 30 | float freqnote; // base frequency 31 | float freqAtual; // current frequency of portamento 32 | float portaFator; // multiplication factor 33 | int portaCont; // samples count 34 | // pitch curve 35 | float curvAtual; // current pitch curve value 36 | float curvFator; // multiplication factor 37 | int curvCont; // samples count 38 | // pan and volume 39 | int lpan; // (Faixa: -1.f a 1.f) Posicionamento entre os canais Esquerdo e Direito 40 | int lvol; // (Faixa: 0.f a 1.f) Volume 41 | // note position 42 | int startPosition;// the sample number of the note begining 43 | int lastpos; // keeps the last position for accuracy of note off 44 | 45 | COscillator osc[6]; 46 | CNoise noise; 47 | CFilter filter; 48 | COscillator lfoosc; 49 | CEnvelop env [MAXOPER + 1 /* LFO envelop */]; 50 | char opstate[MAXOPER + 1 /* LFO envelop */]; 51 | // operators volumes 52 | float opAvol; 53 | float opBvol; 54 | float opCvol; 55 | float opDvol; 56 | float opEvol; 57 | float opFvol; 58 | float opXvol; 59 | float opZvol; 60 | 61 | void SumMonoMono (int *bInput , int *bNoteOut , float volume , int size , int offset ); 62 | void SumMonoStereo (int *bInput , int *bNoteOut , float volume , float pan , int size , int offset); 63 | void PanVolStereo (int *b , int volume , int pan , int size , int offset ); 64 | int enZant; 65 | 66 | float Scaling (unsigned char tecla, float valor); 67 | inline float VelSen (float valor, float vel); 68 | inline float Val2Mul (float valor); 69 | inline float Key2Frequency(char valor); 70 | public: 71 | void Init (SProgram *program, CBuffers *buf, unsigned char key, unsigned char previousKey, float velocity, float samplerate); 72 | void SendEvent(char param, float value, int position); 73 | void Process(int *b, int size, int position); 74 | char GetState(void); 75 | void UpdateProgram (void); 76 | }; 77 | -------------------------------------------------------------------------------- /src/synth/oscillator.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "constants.h" 20 | #include "oscillator.h" 21 | #include "buffers.h" 22 | #include 23 | 24 | #define INPUT_AMOUNT 537 25 | #define INPUT_SHIFT (WAVEFORM_BIT_DEPTH-7) 26 | 27 | void COscillator::Init() 28 | { 29 | sr = 0.f; 30 | fr = 0.f; 31 | tu = 1.f; 32 | pt = 1.f; 33 | phase = 0; 34 | prevout = 0; 35 | self = 0; 36 | bwave = NULL; 37 | hq = true; 38 | freq = 0; 39 | } 40 | 41 | void COscillator::SetPar(char param, float value) 42 | { 43 | switch (param) 44 | { 45 | case SAMPLERATE: 46 | sr = value; 47 | break; 48 | case FREQUENCY: 49 | fr = value; 50 | break; 51 | case TUNING: 52 | tu = value; 53 | break; 54 | case PITCH: 55 | pt = value; 56 | break; 57 | case SELFOSC: 58 | self = lrintf(value * 256.f); 59 | break; 60 | case INTERPOLATION: 61 | hq = value?true:false; 62 | break; 63 | } 64 | // initializes coefficients 65 | freq = lrintf(65536.f * fr * tu * pt * ((float)WAVEFORM_BSIZE) / sr); 66 | } 67 | 68 | void COscillator::SetBuffer(char param, short *b) 69 | { 70 | switch (param) 71 | { 72 | case BWAVE: 73 | bwave = b; 74 | break; 75 | default: 76 | break; 77 | } 78 | } 79 | 80 | void COscillator::Process(int *b, int size, int offset) 81 | { 82 | int i; 83 | int prevphase; 84 | int l1; 85 | int l2; 86 | if (!hq) 87 | { 88 | for (i=offset;i>16]; 95 | b[i] = prevout; 96 | } 97 | } 98 | else 99 | { 100 | for (i=offset;i>16; 107 | l2 = (l1+1) & (WAVEFORM_BSIZE - 1); 108 | prevout = (short)(bwave[l1] + (((bwave[l2] - bwave[l1]) * (prevphase & 0xFFFF))>>16)); 109 | b[i] = prevout; 110 | } 111 | } 112 | } 113 | 114 | float COscillator::Process() // without input, with interpolation, for LFO 115 | { 116 | int l1 = phase>>16; 117 | int l2 = (l1+1) & (WAVEFORM_BSIZE - 1); 118 | phase += freq; 119 | phase &= ((WAVEFORM_BSIZE << 16) - 1); 120 | int sa = bwave[l1] + (((bwave[l2] - bwave[l1]) * (phase & 0xFFFF))>>16); 121 | return float(sa) / 32768.f; 122 | } 123 | -------------------------------------------------------------------------------- /src/synth/oscillator.h: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | class COscillator 20 | { 21 | private: 22 | float sr; // sample rate 23 | float fr; // frequency 24 | float tu; // tune 25 | float pt; // frequency multiplier (pitch curve and LFO) 26 | short prevout; // previous output value 27 | int phase; // current phase 28 | int self; // used for self-modulation 29 | short *bwave; // waveform 30 | bool hq; // high quality (interpolation) 31 | int freq; // constant phase 32 | public: 33 | void Init(); 34 | float Process(); 35 | void SetBuffer(char param, short *b); 36 | void SetPar(char param, float value); 37 | void Process(int *b, int size, int offset); 38 | }; 39 | -------------------------------------------------------------------------------- /src/synth/persist.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "constants.h" 20 | #include "persist.h" 21 | #include "hostinterface.h" 22 | #include "toolkit.h" 23 | #include "programs.h" 24 | #include "bank0.h" 25 | #include "bank1.h" 26 | #include 27 | 28 | CPersist::CPersist() 29 | { 30 | bank_from_host = -1; 31 | banks_count = 0; 32 | memset(banks, 0, sizeof(banks)); 33 | for (int i = 0; i < MAX_BANKS; i++) 34 | { 35 | memset(SoundBankNames[i], 0, TEXT_SIZE); 36 | } 37 | AddBank((void*)bank0, sizeof(bank0), (char*)"bank0 (internal)", false); 38 | AddBank((void*)bank1, sizeof(bank1), (char*)"bank1 (internal)", false); 39 | } 40 | 41 | int CPersist::AddBank(void *bank, unsigned int size, char *name, bool from_host) 42 | { 43 | int index = banks_count; 44 | if (from_host == true) 45 | { 46 | if (bank_from_host > -1) 47 | { 48 | index = bank_from_host; 49 | } 50 | else 51 | { 52 | bank_from_host = banks_count++; 53 | } 54 | } 55 | else if (banks_count >= MAX_BANKS - 1) 56 | { 57 | return -1; 58 | } 59 | else 60 | { 61 | banks_count++; 62 | } 63 | if (bank != NULL && size == SOUNDBANK_SIZE) 64 | { 65 | memcpy(banks[index], bank, size); 66 | strncpy(SoundBankNames[index], name, TEXT_SIZE); 67 | } 68 | return index; 69 | } 70 | 71 | int CPersist::GetNumberBanks() 72 | { 73 | return banks_count; 74 | } 75 | 76 | void CPersist::GetBankName(char *str, int index) 77 | { 78 | strncpy(str, SoundBankNames[index], TEXT_SIZE); 79 | } 80 | 81 | void* CPersist::GetSoundBank(int index) 82 | { 83 | return banks[index]; 84 | } 85 | -------------------------------------------------------------------------------- /src/synth/persist.h: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifdef __OXEDMO__ 20 | typedef void CPersist; 21 | #else 22 | 23 | #define MAX_BANKS 8 24 | #define SOUNDBANK_SIZE 90688 25 | 26 | class CPersist 27 | { 28 | private: 29 | unsigned char banks[MAX_BANKS][SOUNDBANK_SIZE]; 30 | char SoundBankNames[MAX_BANKS][TEXT_SIZE]; 31 | int banks_count; 32 | int bank_from_host; 33 | public: 34 | CPersist(); 35 | int GetNumberBanks(void); 36 | void GetBankName(char *str, int index); 37 | void* GetSoundBank(int index); 38 | int AddBank(void *bank, unsigned int size, char *name, bool from_host); 39 | }; 40 | #endif 41 | -------------------------------------------------------------------------------- /src/synth/reverb.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "constants.h" 20 | #include "reverb.h" 21 | #include 22 | #include 23 | 24 | void CReverb::Init() 25 | { 26 | sr = 0; 27 | ti = 0; 28 | da = 0; 29 | icomb1 = 0; 30 | icomb2 = 0; 31 | icomb3 = 0; 32 | icomb4 = 0; 33 | iallp1 = 0; 34 | iallp2 = 0; 35 | memset(bcomb1,0,sizeof(bcomb1)); 36 | memset(bcomb2,0,sizeof(bcomb2)); 37 | memset(bcomb3,0,sizeof(bcomb3)); 38 | memset(bcomb4,0,sizeof(bcomb4)); 39 | memset(ballp1,0,sizeof(ballp1)); 40 | memset(ballp2,0,sizeof(ballp2)); 41 | state = INACTIVE; 42 | ou0 = 0; 43 | in1 = 0; 44 | in1l = 0; 45 | ou0l = 0; 46 | a0 = 0; 47 | a1 = 0; 48 | b1 = 0; 49 | } 50 | 51 | void CReverb::SetPar(char param, float value) 52 | { 53 | switch (param) 54 | { 55 | case SAMPLERATE: 56 | sr = value; 57 | break; 58 | case TIME: 59 | ti = value; 60 | break; 61 | case DAMP: 62 | da = value; 63 | break; 64 | } 65 | } 66 | 67 | void CReverb::CalcCoefLowPass(float frequencia) 68 | { 69 | float w = 2.0f * sr; 70 | float fCut = 2.0f * PI * Key2Frequency(frequencia * MAXFREQFLT); 71 | float Norm = 1.0f / (fCut + w); 72 | b1 = lrintf((w - fCut) * Norm * 32768.f); 73 | a0 = a1 = lrintf( fCut * Norm * 32768.f); 74 | } 75 | 76 | void CReverb::Process(int *b, int size) 77 | { 78 | int i = 0; 79 | int ent = 0; 80 | int aux = 0; 81 | int retorno = (int)(ti * 127.f); 82 | if (REVDAant != da) 83 | { 84 | CalcCoefLowPass(da); 85 | REVDAant = da; 86 | } 87 | for (i=0;i=TAMCOMB1) icomb1 = 0; 95 | // comb 2 96 | b[i] += bcomb2[icomb2]; 97 | bcomb2[icomb2] = ent + ((bcomb2[icomb2] * retorno)/128); 98 | if (++icomb2>=TAMCOMB2) icomb2 = 0; 99 | // comb 3 100 | b[i] += bcomb3[icomb3]; 101 | bcomb3[icomb3] = ent + ((bcomb3[icomb3] * retorno)/128); 102 | if (++icomb3>=TAMCOMB3) icomb3 = 0; 103 | // comb 4 104 | b[i] += bcomb4[icomb4]; 105 | bcomb4[icomb4] = ent + ((bcomb4[icomb4] * retorno)/128); 106 | if (++icomb4>=TAMCOMB4) icomb4 = 0; 107 | // allpass 1 108 | aux = ballp1[iallp1]; 109 | ballp1[iallp1] = ((aux * retorno)/128) + b[i]; 110 | b[i] = aux - ((ballp1[iallp1] * retorno)/128); 111 | if (++iallp1>=TAMALLP1) iallp1 = 0; 112 | // allpass 2 113 | aux = ballp2[iallp2]; 114 | ballp2[iallp2] = ((aux * retorno)/128) + b[i]; 115 | b[i] = aux - ((ballp2[iallp2] * retorno)/128); 116 | if (++iallp2>=TAMALLP2) iallp2 = 0; 117 | // DC filter 118 | ou0 = b[i] - in1 + ((ou0*32674)/32768); 119 | in1 = b[i]; 120 | b[i] = ou0>>2; 121 | } 122 | if (REVDAant < 1.f) 123 | { 124 | for (i=0;i>1] && !b[size>>2] && !b[size-1]) 134 | state = INACTIVE; 135 | } 136 | 137 | char CReverb::GetState() 138 | { 139 | return state; 140 | } 141 | 142 | inline float CReverb::Key2Frequency(float valor) 143 | { 144 | return C0 * powf(2.0f, valor / 12.0f); 145 | } 146 | -------------------------------------------------------------------------------- /src/synth/reverb.h: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | // buffers sizes 20 | #define TAMCOMB1 1116 // 25ms 21 | #define TAMCOMB2 1277 // 29ms 22 | #define TAMCOMB3 1422 // 32ms 23 | #define TAMCOMB4 1557 // 35ms 24 | #define TAMALLP1 556 // 12ms 25 | #define TAMALLP2 341 // 7ms 26 | 27 | class CReverb 28 | { 29 | private: 30 | float sr; 31 | float ti; // time 32 | float da; // damp 33 | // combs buffers 34 | int bcomb1[TAMCOMB1]; 35 | int bcomb2[TAMCOMB2]; 36 | int bcomb3[TAMCOMB3]; 37 | int bcomb4[TAMCOMB4]; 38 | // allpasses buffers 39 | int ballp1[TAMALLP1]; 40 | int ballp2[TAMALLP2]; 41 | // buffers iterators 42 | int icomb1; 43 | int icomb2; 44 | int icomb3; 45 | int icomb4; 46 | int iallp1; 47 | int iallp2; 48 | // DC filter 49 | int in1; 50 | int ou0; 51 | // low-pass filter 52 | int in1l; 53 | int ou0l; 54 | int a0; 55 | int a1; 56 | int b1; 57 | float REVDAant; 58 | // other 59 | char state; 60 | // calculates low-pass coefs 61 | void CalcCoefLowPass(float frequencia); 62 | public: 63 | void Init(); 64 | char GetState(void); 65 | void Process(int *b, int size); 66 | inline float Key2Frequency(float valor); 67 | void SetPar(char param, float value); 68 | }; 69 | -------------------------------------------------------------------------------- /src/synth/synthesizer.h: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "constants.h" 20 | #include "buffers.h" 21 | #include "hostinterface.h" 22 | #include "toolkit.h" 23 | #include "persist.h" 24 | #include "programs.h" 25 | #include "reverb.h" 26 | #include "oscillator.h" 27 | #include "envelop.h" 28 | #include "noise.h" 29 | #include "filter.h" 30 | #include "delay.h" 31 | #include "note.h" 32 | 33 | class CSynthesizer 34 | { 35 | public: 36 | CBuffers buffers; // auxiliar buffers 37 | private: 38 | float samplerate; 39 | CPrograms programs; 40 | CReverb reverb; 41 | CDelay delay; 42 | CNote notes[POLIPHONY]; 43 | float veloc[POLIPHONY]; // notes velocity 44 | unsigned char state[POLIPHONY]; // notes state 45 | unsigned char channels[POLIPHONY]; // notes channel 46 | unsigned char key[POLIPHONY]; // notes key 47 | unsigned char heldkeys[POLIPHONY]; // notes held by hold pedal 48 | char hld[MIDICHANNELS]; // hold pedal state 49 | unsigned char lkp[MIDICHANNELS]; // last key pressed 50 | float rev[MIDICHANNELS]; // reverb value 51 | float dly[MIDICHANNELS]; // delay value 52 | float mod[MIDICHANNELS]; // modulation wheel value 53 | float vol[MIDICHANNELS]; // volume 54 | float pan[MIDICHANNELS]; // pan 55 | float aft[MIDICHANNELS]; // aftertouch 56 | float ptc[MIDICHANNELS]; // pitch wheel 57 | int activeNotesCount; // active notes count 58 | char revrbON; // reverb on 59 | char delayON; // delay on 60 | // sum signals 61 | void SumMonoStereo (int *bInput, int *bNoteOut, int size); 62 | void SumStereoMono (int *bInput, int *bNoteOut, float volume, int size); 63 | void SumStereoStereo (int *bInput, int *bNoteOut, float volume, int size); 64 | inline float Val2Mul (float valor); 65 | void UpdateGlobalEffects (); 66 | public: 67 | CSynthesizer(); 68 | void SetSampleRate (float samplerate); 69 | void Process (int *b, int size, int position /* the start sample number */); 70 | void SendEvent (unsigned char bS, unsigned char bD1,unsigned char bD2,int position /* the start position */); 71 | void KillNotes (void); 72 | void AllNotesOff (int position); 73 | char GetState (); 74 | #ifndef __OXEDMO__ 75 | float SetDefault (char channel, int par ); 76 | void SetPar (char channel, int par, float val); 77 | float GetPar (char channel, int par ); 78 | bool GetStandBy (char channel); 79 | void SetStandBy (char channel, bool isWaiting); 80 | bool IsEditingName (); 81 | void SetEditingName (bool value); 82 | bool GetBankMode (); 83 | void SetBankMode (bool bankMode); 84 | unsigned char GetNumProgr (char channel); 85 | void GetProgName (char *str, char channel); 86 | void SetProgName (char *str, char channel); 87 | void GetProgName (char *str, int numpg); 88 | void SetProgName (char *str, int numpg); 89 | void GetBankName (char *str); 90 | int GetBankCount (); 91 | int GetBankIndex (); 92 | void SetBankIndex (int nbank); 93 | void StoreProgram (char channel); 94 | SBank* GetBank (void); 95 | void CopyProgram (int destination, int source); 96 | void SetBank (SBank *bank); 97 | void SetProgram (char numprg, SProgram *program); 98 | bool HasChanges (); 99 | void SetHostInterface(CHostInterface *hostinterface); 100 | #endif 101 | }; 102 | -------------------------------------------------------------------------------- /src/toolkits/bitmaps.h: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | extern const char *chars_bmp; 20 | extern const char *knob_bmp; 21 | extern const char *knob2_bmp; 22 | extern const char *knob3_bmp; 23 | extern const char *key_bmp; 24 | extern const char *bg_bmp; 25 | extern const char *buttons_bmp; 26 | extern const char *ops_bmp; 27 | -------------------------------------------------------------------------------- /src/toolkits/cocoatoolkit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "editor.h" 20 | #include "cocoawrapper.h" 21 | #if defined(__linux) 22 | #include 23 | #else 24 | #include 25 | #endif 26 | #include "opengltoolkit.h" 27 | #include "cocoatoolkit.h" 28 | #include 29 | #include 30 | #ifndef __USE_GNU 31 | #define __USE_GNU 32 | #endif 33 | #include 34 | #define PATH_MAX 512 35 | 36 | void GetResourcesPath(char *path, int size) 37 | { 38 | Dl_info info; 39 | dladdr((void*)GetResourcesPath, &info); 40 | strncpy(path, info.dli_fname, PATH_MAX); 41 | char* tmp = strrchr(path, '/'); 42 | *tmp = 0; 43 | strcat(path, "/../../../"BMP_PATH"/"); 44 | } 45 | 46 | CCocoaToolkit::CCocoaToolkit(void *parentWindow, CEditor *editor) 47 | { 48 | this->parentWindow = parentWindow; 49 | this->editor = editor; 50 | this->objcInstance = CocoaToolkitCreate((void*)this); 51 | CocoaToolkitCreateWindow(this->objcInstance, parentWindow); 52 | } 53 | 54 | CCocoaToolkit::~CCocoaToolkit() 55 | { 56 | CocoaToolkitDestroy(this->objcInstance); 57 | } 58 | 59 | void CCocoaToolkit::StartWindowProcesses() 60 | { 61 | CocoaToolkitShowWindow(this->objcInstance); 62 | } 63 | 64 | int CCocoaToolkit::WaitWindowClosed() 65 | { 66 | CocoaToolkitWaitWindowClosed(this->objcInstance); 67 | return 0; 68 | } 69 | 70 | void CppOnLButtonDown(void *toolkit, int x, int y) 71 | { 72 | ((CCocoaToolkit*)toolkit)->editor->OnLButtonDown(x, y); 73 | } 74 | 75 | void CppOnLButtonUp(void *toolkit) 76 | { 77 | ((CCocoaToolkit*)toolkit)->editor->OnLButtonUp(); 78 | } 79 | 80 | void CppOnDblClick(void *toolkit, int x, int y) 81 | { 82 | ((CCocoaToolkit*)toolkit)->editor->OnLButtonDblClick(x, y); 83 | } 84 | 85 | void CppOnMouseMove(void *toolkit, int x, int y) 86 | { 87 | ((CCocoaToolkit*)toolkit)->editor->OnMouseMove(x, y); 88 | } 89 | 90 | void CppOnChar(void *toolkit, int c) 91 | { 92 | ((CCocoaToolkit*)toolkit)->editor->OnChar(c); 93 | } 94 | 95 | void CppOpenGLInit(void *toolkit) 96 | { 97 | CCocoaToolkit *t = (CCocoaToolkit*)toolkit; 98 | char path[PATH_MAX]; 99 | GetResourcesPath(path, sizeof(path)); 100 | t->Init(t->editor, path); 101 | } 102 | 103 | void CppOpenGLDeinit(void *toolkit) 104 | { 105 | ((CCocoaToolkit*)toolkit)->Deinit(); 106 | } 107 | 108 | void CppOpenGLDraw(void *toolkit) 109 | { 110 | ((CCocoaToolkit*)toolkit)->Draw(); 111 | } 112 | -------------------------------------------------------------------------------- /src/toolkits/cocoatoolkit.h: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | class CCocoaToolkit : public COpenGLToolkit 20 | { 21 | private: 22 | void *objcInstance; 23 | public: 24 | void *parentWindow; 25 | CEditor *editor; 26 | CCocoaToolkit(void *parentWindow, CEditor *editor); 27 | ~CCocoaToolkit(); 28 | void StartWindowProcesses(); 29 | int WaitWindowClosed(); 30 | }; 31 | -------------------------------------------------------------------------------- /src/toolkits/cocoatoolkit.m: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #import "constants.h" 20 | #import "cocoawrapper.h" 21 | #import 22 | 23 | @interface PluginView : NSOpenGLView 24 | { 25 | void* toolkit; 26 | } 27 | - (id) init:(void*)toolkitPtr withSize:(NSSize)size; 28 | - (void) viewDidMoveToWindow; 29 | - (void) mouseDown:(NSEvent *)event; 30 | - (void) mouseUp:(NSEvent *)event; 31 | - (void) mouseMoved:(NSEvent *)event; 32 | - (void) mouseDragged:(NSEvent *)event; 33 | - (void) keyDown:(NSEvent *)event; 34 | - (BOOL) isOpaque; 35 | @end 36 | 37 | @interface CocoaToolkit : NSObject 38 | { 39 | void* toolkit; 40 | NSView* parentView; 41 | NSAutoreleasePool* pool; 42 | NSApplication* app; 43 | NSWindow* window; 44 | PluginView* view; 45 | NSImage* bmps[BMP_COUNT]; 46 | int bmps_height[BMP_COUNT]; 47 | NSTimer* timer; 48 | } 49 | - (id) initWithToolkit:(void*)toolkitPtr; 50 | - (void) createWindow:(id)parent; 51 | - (void) showWindow; 52 | - (void) waitWindowClosed; 53 | - (void) update; 54 | @end 55 | 56 | //---------------------------------------------------------------------- 57 | 58 | @implementation PluginView 59 | 60 | - (id) init:(void*)toolkitPtr withSize:(NSSize)size 61 | { 62 | toolkit = toolkitPtr; 63 | 64 | NSRect frame = NSMakeRect(0, 0, size.width, size.height); 65 | 66 | NSOpenGLPixelFormatAttribute pixelAttribs[16] = 67 | { 68 | NSOpenGLPFADoubleBuffer, 69 | NSOpenGLPFAAccelerated, 70 | NSOpenGLPFAColorSize, 32, 71 | NSOpenGLPFADepthSize, 32, 72 | 0 73 | }; 74 | 75 | NSOpenGLPixelFormat* pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:pixelAttribs]; 76 | if (pixelFormat) 77 | { 78 | self = [super initWithFrame:frame pixelFormat:pixelFormat]; 79 | [pixelFormat release]; 80 | } 81 | else 82 | { 83 | self = [super initWithFrame:frame]; 84 | } 85 | if (self) 86 | { 87 | [[self openGLContext] makeCurrentContext]; 88 | CppOpenGLInit(toolkit); 89 | } 90 | return self; 91 | } 92 | 93 | - (void) dealloc 94 | { 95 | CppOpenGLDeinit(toolkit); 96 | [super dealloc]; 97 | } 98 | 99 | - (void) drawRect:(NSRect)rect 100 | { 101 | CppOpenGLDraw(toolkit); 102 | [[self openGLContext] flushBuffer]; 103 | } 104 | 105 | - (void)viewDidMoveToWindow { 106 | [self addTrackingRect:NSMakeRect(0, 0, GUI_WIDTH, GUI_HEIGHT) owner:self userData:NULL assumeInside:NO]; 107 | } 108 | 109 | - (BOOL) isOpaque 110 | { 111 | return YES; 112 | } 113 | 114 | - (void) mouseEntered:(NSEvent *)theEvent 115 | { 116 | [[self window] setAcceptsMouseMovedEvents: YES]; 117 | [[self window] makeFirstResponder:self]; 118 | } 119 | 120 | - (void) mouseDown:(NSEvent *)event 121 | { 122 | NSPoint loc = [self convertPoint:[event locationInWindow] fromView:nil]; 123 | CppOnLButtonDown(toolkit, (int)loc.x, GUI_HEIGHT - (int)loc.y); 124 | } 125 | 126 | - (void) mouseUp:(NSEvent *)event 127 | { 128 | CppOnLButtonUp(toolkit); 129 | if ([event clickCount] == 2) 130 | { 131 | NSPoint loc = [self convertPoint:[event locationInWindow] fromView:nil]; 132 | CppOnDblClick(toolkit, (int)loc.x, GUI_HEIGHT - (int)loc.y); 133 | } 134 | } 135 | 136 | - (void) mouseMoved:(NSEvent *)event 137 | { 138 | NSPoint loc = [self convertPoint:[event locationInWindow] fromView:nil]; 139 | CppOnMouseMove(toolkit, (int)loc.x, GUI_HEIGHT - (int)loc.y); 140 | } 141 | 142 | - (void) mouseDragged:(NSEvent *)event; 143 | { 144 | NSPoint loc = [self convertPoint:[event locationInWindow] fromView:nil]; 145 | CppOnMouseMove(toolkit, (int)loc.x, GUI_HEIGHT - (int)loc.y); 146 | } 147 | 148 | - (void) keyDown:(NSEvent *)event 149 | { 150 | const char *c = [[event characters] UTF8String]; 151 | CppOnChar(toolkit, (int)c[0]); 152 | } 153 | 154 | @end 155 | 156 | //---------------------------------------------------------------------- 157 | 158 | @implementation CocoaToolkit 159 | 160 | /** 161 | * wrappers start 162 | **/ 163 | void* CocoaToolkitCreate(void* toolkit) 164 | { 165 | return [[CocoaToolkit alloc] initWithToolkit:toolkit]; 166 | } 167 | 168 | void CocoaToolkitDestroy(void *self) 169 | { 170 | [(id)self dealloc]; 171 | } 172 | 173 | void CocoaToolkitCreateWindow(void *self, void* parent) 174 | { 175 | [(id)self createWindow:(id)parent]; 176 | } 177 | 178 | void CocoaToolkitShowWindow(void *self) 179 | { 180 | [(id)self showWindow]; 181 | } 182 | 183 | void CocoaToolkitWaitWindowClosed(void *self) 184 | { 185 | [(id)self waitWindowClosed]; 186 | } 187 | /** 188 | * wrappers end 189 | **/ 190 | 191 | - (id) initWithToolkit:(void*)toolkitPtr 192 | { 193 | self = [super init]; 194 | if (self) 195 | { 196 | pool = [[NSAutoreleasePool alloc] init]; 197 | toolkit = toolkitPtr; 198 | } 199 | return self; 200 | } 201 | 202 | - (void) dealloc 203 | { 204 | [timer invalidate]; 205 | [view release]; 206 | if (window) 207 | { 208 | [window release]; 209 | } 210 | if (pool) 211 | { 212 | [pool release]; 213 | } 214 | if (parentView) 215 | { 216 | [parentView release]; 217 | } 218 | [super dealloc]; 219 | } 220 | 221 | - (void) createWindow:(id)parent 222 | { 223 | if (!parent) 224 | { 225 | app = [NSApplication sharedApplication]; 226 | } 227 | view = [[PluginView alloc] init:toolkit withSize:NSMakeSize(GUI_WIDTH, GUI_HEIGHT)]; 228 | if (parent) 229 | { 230 | [pool release]; 231 | pool = NULL; 232 | parentView = [(NSView*) parent retain]; 233 | [parentView addSubview: view]; 234 | } 235 | else 236 | { 237 | NSRect rect = NSMakeRect(0, 0, GUI_WIDTH, GUI_HEIGHT); 238 | window = [[NSWindow alloc] 239 | initWithContentRect: rect 240 | styleMask: NSClosableWindowMask | NSTitledWindowMask 241 | backing: NSBackingStoreBuffered 242 | defer:NO 243 | ]; 244 | [window setTitle:@TITLE_FULL]; 245 | [window center]; 246 | [window setContentView: view]; 247 | [NSApp setDelegate:(id)self]; 248 | } 249 | } 250 | 251 | - (void) showWindow 252 | { 253 | [[view window] setAutodisplay: YES]; 254 | if (window) 255 | { 256 | [window makeKeyAndOrderFront:nil]; 257 | } 258 | else 259 | { 260 | [[view window] orderFront:nil]; 261 | } 262 | [[view window] makeKeyAndOrderFront:nil]; 263 | timer = [NSTimer scheduledTimerWithTimeInterval:(0.001 * TIMER_RESOLUTION_MS) 264 | target:self 265 | selector:@selector(update) 266 | userInfo:nil 267 | repeats:YES]; 268 | } 269 | 270 | - (void) waitWindowClosed 271 | { 272 | [app run]; 273 | } 274 | 275 | - (BOOL) applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication 276 | { 277 | return YES; 278 | } 279 | 280 | - (void) update 281 | { 282 | [view setNeedsDisplay: YES]; 283 | } 284 | 285 | @end 286 | -------------------------------------------------------------------------------- /src/toolkits/cocoawrapper.h: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifdef __cplusplus 20 | extern "C" 21 | { 22 | #endif 23 | 24 | void* CocoaToolkitCreate(void *toolkit); 25 | void CocoaToolkitDestroy(void *self); 26 | void CocoaToolkitCreateWindow(void *self, void *parent); 27 | void CocoaToolkitShowWindow(void *self); 28 | void CocoaToolkitWaitWindowClosed(void *self); 29 | 30 | void CppOnLButtonDown(void *toolkit, int x, int y); 31 | void CppOnLButtonUp(void *toolkit); 32 | void CppOnDblClick(void *toolkit, int x, int y); 33 | void CppOnMouseMove(void *toolkit, int x, int y); 34 | void CppOnChar(void *toolkit, int c); 35 | void CppUpdate(void *toolkit); 36 | void CppOpenGLInit(void *toolkit); 37 | void CppOpenGLDeinit(void *toolkit); 38 | void CppOpenGLDraw(void *toolkit); 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | -------------------------------------------------------------------------------- /src/toolkits/embedresources.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include 20 | 21 | #define PATH "skins/default/" 22 | 23 | void append_file(FILE *fout, const char *path, const char *name) 24 | { 25 | FILE *f = fopen(path, "rb"); 26 | unsigned char c; 27 | unsigned int i = 0; 28 | fprintf(fout, "const unsigned char _%s[] = {\n", name); 29 | while (!feof(f)) 30 | { 31 | (void)fread(&c, 1, 1, f); 32 | fprintf(fout, "0x%02X%s%s", c, !feof(f) ? "," : "", ++i % 16 ? "" : "\n"); 33 | } 34 | fprintf(fout, "};\n"); 35 | fprintf(fout, "const char *%s = (const char *)_%s;\n", name, name); 36 | fclose(f); 37 | } 38 | 39 | int main(int argc, char *argv[]) 40 | { 41 | if (argc != 2 || argv[1][0] == 0) 42 | { 43 | return 1; 44 | } 45 | FILE *f = fopen(argv[1], "wb"); 46 | if (!f) 47 | { 48 | return 2; 49 | } 50 | append_file(f, PATH"bg.bmp" , "bg_bmp" ); 51 | append_file(f, PATH"buttons.bmp", "buttons_bmp"); 52 | append_file(f, PATH"chars.bmp" , "chars_bmp" ); 53 | append_file(f, PATH"key.bmp" , "key_bmp" ); 54 | append_file(f, PATH"knob2.bmp" , "knob2_bmp" ); 55 | append_file(f, PATH"knob3.bmp" , "knob3_bmp" ); 56 | append_file(f, PATH"knob.bmp" , "knob_bmp" ); 57 | append_file(f, PATH"ops.bmp" , "ops_bmp" ); 58 | fclose(f); 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /src/toolkits/hostinterface.h: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifndef __OXEDMO__ 20 | 21 | class CHostInterface 22 | { 23 | public: 24 | virtual void ReceiveMessageFromPlugin(unsigned int messageID, unsigned int par1, unsigned int par2) {} 25 | }; 26 | 27 | enum { 28 | UPDATE_DISPLAY, 29 | SET_PROGRAM , 30 | SET_PARAMETER 31 | }; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/toolkits/nonguitoolkit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #if defined(__linux) 20 | #include 21 | #include 22 | #elif defined(__APPLE__) 23 | #include 24 | #else 25 | #include 26 | #endif 27 | unsigned int GetTick() 28 | { 29 | #if defined(__linux) 30 | struct timespec ts; 31 | unsigned int theTick = 0U; 32 | clock_gettime(CLOCK_MONOTONIC, &ts); 33 | theTick = ts.tv_nsec / 1000000; 34 | theTick += ts.tv_sec * 1000; 35 | return theTick; 36 | #elif defined(__APPLE__) 37 | mach_timebase_info_data_t info; 38 | mach_timebase_info(&info); 39 | uint64_t value = mach_absolute_time(); 40 | value *= info.numer; 41 | value /= info.denom; 42 | value /= 1000000; 43 | return (unsigned int)value; 44 | #else 45 | return (unsigned int)GetTickCount(); 46 | #endif 47 | } 48 | -------------------------------------------------------------------------------- /src/toolkits/nonguitoolkit.h: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | unsigned int GetTick(); 20 | -------------------------------------------------------------------------------- /src/toolkits/opengltoolkit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "bitmaps.h" 20 | #include "editor.h" 21 | #if defined(__linux) 22 | #define GL_GLEXT_PROTOTYPES 23 | #include 24 | #elif defined(__APPLE__) 25 | #include 26 | #endif 27 | #include "opengltoolkit.h" 28 | #include 29 | #include 30 | 31 | #define TEX_WIDTH (633 + 250 + 5 /* to align */) 32 | #define TEX_HEIGHT (250 + 200 + 200 + 6 /* to align */) 33 | #define PIXEL_BYTES 4 /* RGBA */ 34 | #define TOTAL_INDICES ((1 /*<- bg */ + COORDS_COUNT) * TWO_TRIANGLES) 35 | 36 | int texCoods[][2] = 37 | { 38 | { 0, 437}, // BMP_CHARS 39 | {633, 0}, // BMP_KNOB 40 | {633, 250}, // BMP_KNOB2 41 | {633, 450}, // BMP_KNOB3 42 | { 80, 437}, // BMP_KEY 43 | { 0, 0}, // BMP_BG 44 | {100, 437}, // BMP_BUTTONS 45 | {142, 437} // BMP_OPS 46 | }; 47 | 48 | typedef struct __attribute__((packed)) 49 | { 50 | char signature[2]; 51 | unsigned int fileSize; 52 | short reserved[2]; 53 | unsigned int fileOffsetToPixelArray; 54 | } BITMAPFILEHEADER; 55 | 56 | typedef struct __attribute__((packed)) 57 | { 58 | unsigned int dibHeaderSize; 59 | unsigned int width; 60 | unsigned int height; 61 | unsigned short planes; 62 | unsigned short bitsPerPixel; 63 | unsigned int compression; 64 | unsigned int imageSize; 65 | } BITMAPV5HEADER; 66 | 67 | typedef struct 68 | { 69 | BITMAPFILEHEADER fh; 70 | BITMAPV5HEADER v5; 71 | } BITMAPHEADER; 72 | 73 | void COpenGLToolkit::Init(CEditor *editor, char *skinPath) 74 | { 75 | this->editor = editor; 76 | 77 | unsigned char *rawBigTexture = (unsigned char*)malloc(TEX_WIDTH * TEX_HEIGHT * PIXEL_BYTES); 78 | loadImageToBuffer(rawBigTexture, texCoods[BMP_CHARS ][0], texCoods[BMP_CHARS ][1], (unsigned char *)chars_bmp , skinPath, "chars.bmp" ); 79 | loadImageToBuffer(rawBigTexture, texCoods[BMP_KNOB ][0], texCoods[BMP_KNOB ][1], (unsigned char *)knob_bmp , skinPath, "knob.bmp" ); 80 | loadImageToBuffer(rawBigTexture, texCoods[BMP_KNOB2 ][0], texCoods[BMP_KNOB2 ][1], (unsigned char *)knob2_bmp , skinPath, "knob2.bmp" ); 81 | loadImageToBuffer(rawBigTexture, texCoods[BMP_KNOB3 ][0], texCoods[BMP_KNOB3 ][1], (unsigned char *)knob3_bmp , skinPath, "knob3.bmp" ); 82 | loadImageToBuffer(rawBigTexture, texCoods[BMP_KEY ][0], texCoods[BMP_KEY ][1], (unsigned char *)key_bmp , skinPath, "key.bmp" ); 83 | loadImageToBuffer(rawBigTexture, texCoods[BMP_BG ][0], texCoods[BMP_BG ][1], (unsigned char *)bg_bmp , skinPath, "bg.bmp" ); 84 | loadImageToBuffer(rawBigTexture, texCoods[BMP_BUTTONS][0], texCoods[BMP_BUTTONS][1], (unsigned char *)buttons_bmp, skinPath, "buttons.bmp"); 85 | loadImageToBuffer(rawBigTexture, texCoods[BMP_OPS ][0], texCoods[BMP_OPS ][1], (unsigned char *)ops_bmp , skinPath, "ops.bmp" ); 86 | 87 | glEnable(GL_TEXTURE_2D); 88 | glGenTextures(1, &texture); 89 | glBindTexture(GL_TEXTURE_2D, texture); 90 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 91 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 92 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TEX_WIDTH, TEX_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, rawBigTexture); 93 | free(rawBigTexture); 94 | 95 | editor->GetCoordinates(this->coords); 96 | 97 | oxeCoords *c; 98 | GLfloat *v; 99 | int i; 100 | 101 | c = this->coords; 102 | v = this->vertices; 103 | i = COORDS_COUNT; 104 | v = updateVerticesXYZ(0, 0, GUI_WIDTH, GUI_HEIGHT, GUI_WIDTH, GUI_HEIGHT, v); // bg 105 | while (i--) 106 | { 107 | v = updateVerticesXYZ(c->destX, c->destY, c->width, c->height, GUI_WIDTH, GUI_HEIGHT, v); 108 | c++; 109 | } 110 | 111 | c = this->coords; 112 | v = this->texCoords; 113 | i = COORDS_COUNT; 114 | v = updateVerticesUV(0, 0, GUI_WIDTH, GUI_HEIGHT, BMP_BG, v); // bg 115 | while (i--) 116 | { 117 | v = updateVerticesUV(c->origX, c->origY, c->width, c->height, c->origBmp, v); 118 | c++; 119 | } 120 | 121 | glEnableClientState(GL_VERTEX_ARRAY); 122 | glGenBuffers(1, &vertexBuffer); 123 | glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer); 124 | glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); 125 | glVertexPointer(3, GL_FLOAT, 0, 0); 126 | 127 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); 128 | glGenBuffers(1, &coordsBuffer); 129 | glBindBuffer(GL_ARRAY_BUFFER, coordsBuffer); 130 | glBufferData(GL_ARRAY_BUFFER, sizeof(texCoords), texCoords, GL_DYNAMIC_DRAW); 131 | glTexCoordPointer(2, GL_FLOAT, 0, 0); 132 | } 133 | 134 | void COpenGLToolkit::Deinit() 135 | { 136 | glDeleteTextures(1, &texture); 137 | glDeleteBuffers(1, &vertexBuffer); 138 | glDeleteBuffers(1, &coordsBuffer); 139 | } 140 | 141 | void COpenGLToolkit::loadImageToBuffer(unsigned char *destB, int destX, int destY, unsigned char *buffer, char *skinPath, const char *filename) 142 | { 143 | unsigned char *tmp = NULL; 144 | char path[512]; 145 | snprintf(path, sizeof(path), "%s%s", skinPath, filename); 146 | FILE *f = fopen(path, "rb"); 147 | if (f) 148 | { 149 | fseek(f, 0, SEEK_END); 150 | int size = ftell(f); 151 | fseek(f, 0, SEEK_SET); 152 | tmp = (unsigned char*)malloc(size); 153 | if (!fread(tmp, size, 1, f)) 154 | { 155 | free(tmp); 156 | tmp = NULL; 157 | } 158 | else 159 | { 160 | buffer = tmp; 161 | } 162 | fclose(f); 163 | } 164 | BITMAPHEADER *header = (BITMAPHEADER *)buffer; 165 | if (header->fh.signature[0] != 'B' || header->fh.signature[1] != 'M') 166 | { 167 | if (tmp) 168 | { 169 | free(tmp); 170 | } 171 | return; 172 | } 173 | if (!header->v5.imageSize) 174 | { 175 | header->v5.imageSize = header->fh.fileSize - sizeof(BITMAPFILEHEADER) - header->v5.dibHeaderSize; 176 | } 177 | unsigned char *data = (unsigned char *)buffer + header->fh.fileOffsetToPixelArray; 178 | unsigned int bytesPerLine = header->v5.imageSize / header->v5.height; 179 | unsigned char *d; 180 | unsigned char *s; 181 | int r, g, b; 182 | int c; 183 | int l = header->v5.height; 184 | while (l) 185 | { 186 | d = destB + (TEX_WIDTH * ((TEX_HEIGHT - 1 - destY) - (header->v5.height - l)) + destX) * PIXEL_BYTES; 187 | c = header->v5.width; 188 | s = data + (--l * bytesPerLine); 189 | while (c--) 190 | { 191 | b = *(s++); 192 | g = *(s++); 193 | r = *(s++); 194 | *(d++) = r; 195 | *(d++) = g; 196 | *(d++) = b; 197 | *(d++) = 0xFF; 198 | } 199 | } 200 | if (tmp) 201 | { 202 | free(tmp); 203 | } 204 | } 205 | 206 | GLfloat* COpenGLToolkit::updateVerticesXYZ(GLfloat x, GLfloat y, GLfloat w, GLfloat h, GLfloat iW, GLfloat iH, GLfloat *v) 207 | { 208 | // flipping 209 | y = iH - y - h; 210 | // ajusts to range -1.0 to 1.0 211 | x /= GUI_WIDTH / 2.f; 212 | y /= GUI_HEIGHT / 2.f; 213 | w /= GUI_WIDTH / 2.f; 214 | h /= GUI_HEIGHT / 2.f; 215 | x -= 1.f; 216 | y -= 1.f; 217 | // triangle 1 218 | *(v++) = x ; *(v++) = y + h; *(v++) = 0; 219 | *(v++) = x + w; *(v++) = y + h; *(v++) = 0; 220 | *(v++) = x + w; *(v++) = y ; *(v++) = 0; 221 | // triangle 2 222 | *(v++) = x + w; *(v++) = y ; *(v++) = 0; 223 | *(v++) = x ; *(v++) = y ; *(v++) = 0; 224 | *(v++) = x ; *(v++) = y + h; *(v++) = 0; 225 | return v; 226 | } 227 | 228 | GLfloat* COpenGLToolkit::updateVerticesUV(GLfloat x, GLfloat y, GLfloat w, GLfloat h, int origBmp, GLfloat *v) 229 | { 230 | // adjusts to the big-composited-texture coordinate 231 | x += texCoods[origBmp][0]; 232 | y += texCoods[origBmp][1]; 233 | // flipping 234 | y = TEX_HEIGHT - y - h; 235 | // ajusts to range 0.0 to 1.0 236 | x /= TEX_WIDTH; 237 | y /= TEX_HEIGHT; 238 | w /= TEX_WIDTH; 239 | h /= TEX_HEIGHT; 240 | // triangle 1 241 | *(v++) = x ; *(v++) = y + h; 242 | *(v++) = x + w; *(v++) = y + h; 243 | *(v++) = x + w; *(v++) = y ; 244 | // triangle 2 245 | *(v++) = x + w; *(v++) = y ; 246 | *(v++) = x ; *(v++) = y ; 247 | *(v++) = x ; *(v++) = y + h; 248 | return v; 249 | } 250 | 251 | void COpenGLToolkit::Draw() 252 | { 253 | GLfloat *v = this->texCoords + COORDS_STRIDE; 254 | this->editor->GetCoordinates(this->coords); 255 | oxeCoords *c = this->coords; 256 | int i = COORDS_COUNT; 257 | while (i--) 258 | { 259 | v = this->updateVerticesUV(c->origX, c->origY, c->width, c->height, c->origBmp, v); 260 | c++; 261 | } 262 | glClear(GL_COLOR_BUFFER_BIT); 263 | glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(this->texCoords), this->texCoords); 264 | glDrawArrays(GL_TRIANGLES, 0, TOTAL_INDICES); 265 | glFlush(); 266 | } 267 | -------------------------------------------------------------------------------- /src/toolkits/opengltoolkit.h: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #define VERTEX_SIZE 3 // vertices 20 | #define COORDS_SIZE 2 // texture coods 21 | #define TWO_TRIANGLES 6 // indices 22 | #define VERTEX_STRIDE (VERTEX_SIZE * TWO_TRIANGLES) 23 | #define COORDS_STRIDE (COORDS_SIZE * TWO_TRIANGLES) 24 | #define TOTAL_VALUES_VER (VERTEX_STRIDE * (1 /*<- bg */ + COORDS_COUNT)) 25 | #define TOTAL_VALUES_TEX (COORDS_STRIDE * (1 /*<- bg */ + COORDS_COUNT)) 26 | 27 | class COpenGLToolkit : public CToolkit 28 | { 29 | private: 30 | GLuint texture; 31 | GLuint vertexBuffer; 32 | GLuint coordsBuffer; 33 | oxeCoords coords[COORDS_COUNT]; 34 | GLfloat vertices [TOTAL_VALUES_VER]; 35 | GLfloat texCoords[TOTAL_VALUES_TEX]; 36 | CEditor *editor; 37 | void loadImageToBuffer(unsigned char *destB, int destX, int destY, unsigned char *buffer, char *skinPath, const char *filename); 38 | GLfloat* updateVerticesXYZ(GLfloat x, GLfloat y, GLfloat w, GLfloat h, GLfloat iW, GLfloat iH, GLfloat *v); 39 | GLfloat* updateVerticesUV(GLfloat x, GLfloat y, GLfloat w, GLfloat h, int origBmp, GLfloat *v); 40 | public: 41 | void Init(CEditor *editor, char *skinPath); 42 | void Draw(); 43 | void Deinit(); 44 | }; 45 | -------------------------------------------------------------------------------- /src/toolkits/ostoolkit.h: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #if defined(__APPLE__) 20 | #include 21 | #include "opengltoolkit.h" 22 | #include "cocoatoolkit.h" 23 | #define COSToolkit CCocoaToolkit 24 | #elif defined(__linux) 25 | #include 26 | #include 27 | #ifdef USE_OPENGL 28 | #include 29 | #include "opengltoolkit.h" 30 | #endif 31 | #include "xlibtoolkit.h" 32 | #define COSToolkit CXlibToolkit 33 | #else 34 | #include 35 | #include "windowstoolkit.h" 36 | #define COSToolkit CWindowsToolkit 37 | #endif 38 | -------------------------------------------------------------------------------- /src/toolkits/toolkit.h: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifndef __OXEDMO__ 20 | 21 | class CToolkit 22 | { 23 | public: 24 | virtual ~CToolkit() {} 25 | virtual void CopyRect(int destX, int destY, int width, int height, int origBmp, int origX, int origY) {} 26 | virtual void StartMouseCapture() {} 27 | virtual void StopMouseCapture() {} 28 | virtual void StartWindowProcesses() {} 29 | virtual int WaitWindowClosed() {return 0;} // standalone only 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/toolkits/windowstoolkit.h: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | class CWindowsToolkit : public CToolkit 20 | { 21 | private: 22 | HWND hWnd; 23 | HDC hdc; 24 | HDC hdcAux; 25 | HBITMAP bitmap; 26 | HBITMAP bmps[BMP_COUNT]; 27 | public: 28 | void *parentWindow; 29 | CEditor *editor; 30 | HDC hdcMem; 31 | CWindowsToolkit(void *parentWindow, CEditor *editor); 32 | ~CWindowsToolkit(); 33 | void StartWindowProcesses(); 34 | void CopyRect(int destX, int destY, int width, int height, int origBmp, int origX, int origY); 35 | void StartMouseCapture(); 36 | void StopMouseCapture(); 37 | int WaitWindowClosed(); 38 | }; 39 | -------------------------------------------------------------------------------- /src/toolkits/xlibtoolkit.h: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | class CXlibToolkit 20 | #ifdef USE_OPENGL 21 | : public COpenGLToolkit 22 | #else 23 | : public CToolkit 24 | #endif 25 | { 26 | private: 27 | Pixmap bmps[BMP_COUNT]; 28 | Pixmap LoadImageFromFile(const char *path, XVisualInfo *v); 29 | Pixmap LoadImageFromBuffer(const char *buffer, XVisualInfo *v); 30 | public: 31 | void *parentWindow; 32 | CEditor *editor; 33 | Display *display; 34 | Window window; 35 | GC gc; 36 | Atom WM_DELETE_WINDOW; 37 | Atom WM_TIMER; 38 | Pixmap offscreen; 39 | bool thread1Finished; 40 | bool thread2Finished; 41 | #ifdef USE_OPENGL 42 | GLXContext glxContext; 43 | #endif 44 | bool openGLmode; 45 | CXlibToolkit(void *parentWindow, CEditor *editor); 46 | ~CXlibToolkit(); 47 | void StartWindowProcesses(); 48 | void CopyRect(int destX, int destY, int width, int height, int origBmp, int origX, int origY); 49 | int WaitWindowClosed(); 50 | }; 51 | -------------------------------------------------------------------------------- /src/vst/oxevst.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "oxevsteditor.h" 20 | #include "oxevst.h" 21 | 22 | COxeVst::COxeVst(audioMasterCallback audioMaster) : AudioEffectX(audioMaster, kNumPrograms, kNumParams) 23 | { 24 | editor = new COxeVstEditor(this, &synthesizer); 25 | if (!editor) 26 | { 27 | return; 28 | } 29 | if (audioMaster) 30 | { 31 | setUniqueID (CCONST('O','X','F','M')); 32 | setNumInputs (0); 33 | setNumOutputs (kNumOutputs); 34 | canProcessReplacing (); 35 | programsAreChunks (); 36 | isSynth (); 37 | } 38 | suspend(); 39 | posExt = 0; 40 | posInt = 0; 41 | bufferPos = 0; 42 | memset(&events,0,sizeof(events)); 43 | } 44 | 45 | COxeVst::~COxeVst() 46 | { 47 | delete editor; 48 | editor = NULL; 49 | } 50 | 51 | void COxeVst::setProgram(VstInt32 program) 52 | { 53 | AudioEffectX::setProgram(program); 54 | synthesizer.SendEvent(0xC0, getProgram(), 0, 0); 55 | } 56 | 57 | void COxeVst::setProgramOnly(VstInt32 program) 58 | { 59 | AudioEffectX::setProgram(program); 60 | } 61 | 62 | void COxeVst::getProgramName(char *name) // kVstMaxProgNameLen 63 | { 64 | synthesizer.GetProgName(name, getProgram()); 65 | } 66 | 67 | void COxeVst::setProgramName(char *name) // kVstMaxProgNameLen 68 | { 69 | synthesizer.SetProgName(name, getProgram()); 70 | } 71 | 72 | VstInt32 COxeVst::getChunk(void **data, bool isPreset) 73 | { 74 | if (isPreset) 75 | { 76 | *data = &synthesizer.GetBank()->prg[getProgram()]; 77 | return sizeof(SProgram); 78 | } 79 | else 80 | { 81 | *data = synthesizer.GetBank(); 82 | return sizeof(SBank); 83 | } 84 | } 85 | 86 | VstInt32 COxeVst::setChunk(void *data, VstInt32 byteSize, bool isPreset) 87 | { 88 | if (isPreset) 89 | { 90 | if (byteSize != sizeof(SProgram)) 91 | return 0; 92 | synthesizer.SetProgram(getProgram(), (SProgram*)data); 93 | } 94 | else 95 | { 96 | if (byteSize != sizeof(SBank)) 97 | return 0; 98 | synthesizer.SetBank((SBank*)data); 99 | } 100 | return 1; 101 | } 102 | 103 | bool COxeVst::getOutputProperties(VstInt32 index, VstPinProperties* properties) 104 | { 105 | if (index < kNumOutputs) 106 | { 107 | vst_strncpy (properties->label, "Vstx ", 63); 108 | char temp[11] = {0}; 109 | int2string (index + 1, temp, 10); 110 | vst_strncat (properties->label, temp, 63); 111 | 112 | properties->flags = kVstPinIsActive; 113 | if (index < 2) 114 | properties->flags |= kVstPinIsStereo; // make channel 1+2 stereo 115 | return true; 116 | } 117 | return false; 118 | } 119 | 120 | bool COxeVst::getProgramNameIndexed(VstInt32 category, VstInt32 index, char* text) 121 | { 122 | synthesizer.GetProgName(text, index); 123 | if (strlen(text) < 1) 124 | { 125 | vst_strncpy(text, "(empty)", kVstMaxProgNameLen); 126 | } 127 | return true; 128 | } 129 | 130 | bool COxeVst::copyProgram(VstInt32 destination) 131 | { 132 | synthesizer.CopyProgram(destination, getProgram()); 133 | return true; 134 | } 135 | 136 | bool COxeVst::getEffectName(char* name) 137 | { 138 | vst_strncpy(name, "Oxe FM Synth", kVstMaxEffectNameLen); 139 | return true; 140 | } 141 | 142 | bool COxeVst::getVendorString(char* text) 143 | { 144 | vst_strncpy(text, "Oxe Music Software", kVstMaxVendorStrLen); 145 | return true; 146 | } 147 | 148 | bool COxeVst::getProductString(char* text) 149 | { 150 | vst_strncpy(text, "Oxe FM Synth", kVstMaxProductStrLen); 151 | return true; 152 | } 153 | 154 | VstInt32 COxeVst::getVendorVersion() 155 | { 156 | return VERSION_INT; 157 | } 158 | 159 | VstInt32 COxeVst::canDo(char* text) 160 | { 161 | if (!strcmp(text, "receiveVstMidiEvent")) 162 | return 1; 163 | return -1; // explicitly can't do; 0 => don't know 164 | } 165 | 166 | VstInt32 COxeVst::getNumMidiInputChannels() 167 | { 168 | return MIDICHANNELS; 169 | } 170 | 171 | VstInt32 COxeVst::getNumMidiOutputChannels() 172 | { 173 | return 0; 174 | } 175 | 176 | void COxeVst::setSampleRate(float sampleRate) 177 | { 178 | AudioEffectX::setSampleRate(sampleRate); 179 | synthesizer.SetSampleRate(sampleRate); 180 | } 181 | 182 | void COxeVst::suspend() 183 | { 184 | synthesizer.KillNotes(); 185 | } 186 | 187 | void COxeVst::processReplacing(float **inputs, float **outputs, VstInt32 sampleFrames) 188 | { 189 | float *out1 = outputs[0]; 190 | float *out2 = outputs[1]; 191 | 192 | VstInt32 tambufferInt = SAMPLES_PER_PROCESS<<1; 193 | VstInt32 tambufferExt = sampleFrames; 194 | 195 | while (true) 196 | { 197 | if (!posInt) 198 | { 199 | // MIDI ------------------------------------------------------------------------------------------------------- 200 | while (events.eventsCount) 201 | { 202 | if (events.event[events.nextEvent].pos>bufferPos+SAMPLES_PER_PROCESS) 203 | break; 204 | if (events.event[events.nextEvent].pos < bufferPos) 205 | events.event[events.nextEvent].pos = bufferPos; 206 | synthesizer.SendEvent(events.event[events.nextEvent].bstat,events.event[events.nextEvent].bdad1,events.event[events.nextEvent].bdad2,events.event[events.nextEvent].pos); 207 | events.eventsCount--; 208 | events.nextEvent++; 209 | events.nextEvent &= EVENTS_MASK; 210 | } 211 | // ------------------------------------------------------------------------------------------------------------ 212 | synthesizer.Process(synthesizer.buffers.bSynthOut, SAMPLES_PER_PROCESS, bufferPos); 213 | bufferPos += SAMPLES_PER_PROCESS; 214 | } 215 | VstInt32 iaux = min(tambufferInt-posInt,tambufferExt-posExt); 216 | while (iaux>0) 217 | { 218 | out1[posExt] = float(synthesizer.buffers.bSynthOut[posInt++])/32767.f; 219 | out2[posExt] = float(synthesizer.buffers.bSynthOut[posInt++])/32767.f; 220 | posExt++; 221 | iaux-=2; 222 | } 223 | if (posInt >= tambufferInt) 224 | { 225 | posInt = 0; 226 | } 227 | if (posExt >= tambufferExt) 228 | { 229 | posExt = 0; 230 | break; 231 | } 232 | } 233 | } 234 | 235 | VstInt32 COxeVst::processEvents(VstEvents* ev) 236 | { 237 | VstInt32 n; 238 | for (VstInt32 i=0; inumEvents; i++) 239 | { 240 | if ((ev->events[i])->type != kVstMidiType) 241 | continue; 242 | VstMidiEvent* event = (VstMidiEvent*)ev->events[i]; 243 | unsigned char* midiData = (unsigned char*)event->midiData; 244 | n = events.nextEvent + events.eventsCount; 245 | n &= EVENTS_MASK; 246 | events.event[n].bstat = midiData[0]; 247 | events.event[n].bdad1 = midiData[1]; 248 | events.event[n].bdad2 = midiData[2]; 249 | events.event[n].pos = event->deltaFrames + bufferPos; 250 | events.eventsCount++; 251 | } 252 | return 1; 253 | } 254 | 255 | void COxeVst::setParameter (VstInt32 index, float value) 256 | { 257 | ((COxeVstEditor*)editor)->getEditor()->SetPar(index, value); 258 | } 259 | 260 | float COxeVst::getParameter (VstInt32 index) 261 | { 262 | return ((COxeVstEditor*)editor)->getEditor()->GetPar(index); 263 | } 264 | 265 | void COxeVst::getParameterLabel (VstInt32 index, char* label) // kVstMaxParamStrLen 266 | { 267 | ((COxeVstEditor*)editor)->getEditor()->GetParLabel(index, label); 268 | } 269 | 270 | void COxeVst::getParameterDisplay (VstInt32 index, char* text) // kVstMaxParamStrLen 271 | { 272 | ((COxeVstEditor*)editor)->getEditor()->GetParDisplay(index, text); 273 | } 274 | 275 | void COxeVst::getParameterName (VstInt32 index, char* text) // kVstMaxParamStrLen 276 | { 277 | ((COxeVstEditor*)editor)->getEditor()->GetParName(index, text); 278 | } 279 | -------------------------------------------------------------------------------- /src/vst/oxevst.h: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifndef __COxeVst__ 20 | #define __COxeVst__ 21 | 22 | #include 23 | 24 | #ifndef __AudioEffectX__ 25 | #include "public.sdk/source/vst2.x/audioeffectx.h" 26 | #endif 27 | 28 | enum 29 | { 30 | kNumPrograms = MAX_PROGRAMS, 31 | kNumOutputs = STEREOPHONIC, 32 | kNumParams = PARAMETERS_COUNT 33 | }; 34 | 35 | #define MAX_EVENTS_AT_ONCE_POWEROFTWO 8 36 | #define EVENTS_MASK ((1< 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "public.sdk/source/vst2.x/audioeffectx.h" 20 | #include "oxevsteditor.h" 21 | #include "ostoolkit.h" 22 | 23 | //----------------------------------------------------------------------------- 24 | 25 | COxeVstEditor::COxeVstEditor (AudioEffectX *effectx, CSynthesizer *synth) 26 | : 27 | AEffEditor(effectx), 28 | effectx(effectx) 29 | { 30 | oxeeditor = new CEditor(synth); 31 | effect->setEditor(this); 32 | hostinterface = NULL; 33 | toolkit = NULL; 34 | } 35 | 36 | //----------------------------------------------------------------------------- 37 | 38 | COxeVstEditor::~COxeVstEditor () 39 | { 40 | delete oxeeditor; 41 | } 42 | 43 | //----------------------------------------------------------------------------- 44 | 45 | bool COxeVstEditor::getRect (ERect **erect) 46 | { 47 | static ERect r = {0, 0, GUI_HEIGHT, GUI_WIDTH }; 48 | *erect = &r; 49 | return true; 50 | } 51 | 52 | //----------------------------------------------------------------------------- 53 | 54 | bool COxeVstEditor::open (void *ptr) 55 | { 56 | // Remember the parent window 57 | systemWindow = ptr; 58 | 59 | hostinterface = new CVstHostInterface(effectx); 60 | toolkit = new COSToolkit(ptr, oxeeditor); 61 | oxeeditor->SetToolkit(toolkit); 62 | oxeeditor->SetHostInterface(hostinterface); 63 | this->toolkit->StartWindowProcesses(); 64 | return true; 65 | } 66 | 67 | //----------------------------------------------------------------------------- 68 | 69 | void COxeVstEditor::close () 70 | { 71 | oxeeditor->SetToolkit(NULL); 72 | oxeeditor->SetHostInterface(NULL); 73 | delete toolkit; 74 | toolkit = NULL; 75 | delete hostinterface; 76 | hostinterface = NULL; 77 | } 78 | -------------------------------------------------------------------------------- /src/vst/oxevsteditor.h: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "public.sdk/source/vst2.x/aeffeditor.h" 20 | #include "editor.h" 21 | #include "vsthostinterface.h" 22 | 23 | //----------------------------------------------------------------------------- 24 | 25 | class COxeVstEditor : public AEffEditor 26 | { 27 | public: 28 | COxeVstEditor(AudioEffectX *effect, CSynthesizer *synth); 29 | virtual ~COxeVstEditor(); 30 | 31 | virtual bool getRect(ERect **rect); 32 | virtual bool open(void *ptr); 33 | virtual void close(); 34 | 35 | CEditor* getEditor() { return oxeeditor; } 36 | private: 37 | AudioEffectX* effectx; 38 | CEditor* oxeeditor; 39 | CToolkit* toolkit; 40 | CVstHostInterface* hostinterface; 41 | }; 42 | 43 | //----------------------------------------------------------------------------- 44 | -------------------------------------------------------------------------------- /src/vst/oxevstmain.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "oxevsteditor.h" 20 | #include "oxevst.h" 21 | 22 | AudioEffect* createEffectInstance (audioMasterCallback audioMaster) 23 | { 24 | return new COxeVst (audioMaster); 25 | } 26 | -------------------------------------------------------------------------------- /src/vst/vsthostinterface.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "public.sdk/source/vst2.x/audioeffectx.h" 20 | #include "synthesizer.h" 21 | #include "vsthostinterface.h" 22 | #include "oxevst.h" 23 | 24 | CVstHostInterface::CVstHostInterface(AudioEffectX *effectx) 25 | { 26 | this->effectx = effectx; 27 | } 28 | 29 | void CVstHostInterface::ReceiveMessageFromPlugin(unsigned int messageID, unsigned int par1, unsigned int par2) 30 | { 31 | switch (messageID) 32 | { 33 | case UPDATE_DISPLAY: 34 | { 35 | if (effectx) 36 | { 37 | effectx->updateDisplay(); 38 | } 39 | break; 40 | } 41 | case SET_PROGRAM: 42 | { 43 | unsigned char numprog = (unsigned char)par2; 44 | ((COxeVst*)effectx)->setProgramOnly(numprog); 45 | effectx->updateDisplay(); 46 | break; 47 | } 48 | case SET_PARAMETER: 49 | { 50 | int index = (int)par1; 51 | float value = (float)par2 / MAXPARVALUE; 52 | if (effectx) 53 | { 54 | effectx->setParameterAutomated(index, value); 55 | } 56 | break; 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/vst/vsthostinterface.h: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | class CVstHostInterface : public CHostInterface 20 | { 21 | private: 22 | AudioEffectX *effectx; 23 | public: 24 | CVstHostInterface(AudioEffectX *effectx); 25 | void ReceiveMessageFromPlugin(unsigned int messageID, unsigned int par1, unsigned int par2); 26 | }; 27 | -------------------------------------------------------------------------------- /src/windows/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oxesoft/oxefmsynth/fe078ea036991081c3a28bb388a3fecd0e8e3a5d/src/windows/icon.ico -------------------------------------------------------------------------------- /src/windows/resources.h: -------------------------------------------------------------------------------- 1 | /* 2 | Oxe FM Synth: a software synthesizer 3 | Copyright (C) 2004-2015 Daniel Moura 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #define IDI_ICON 100 20 | #define IDB_CHARS 101 21 | #define IDB_KNOB 102 22 | #define IDB_KNOB2 103 23 | #define IDB_KNOB3 104 24 | #define IDB_CHAVE 105 25 | #define IDB_FUNDO 106 26 | #define IDB_BUTTONS 107 27 | #define IDB_OPS 108 28 | -------------------------------------------------------------------------------- /src/windows/resources.rc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "resources.h" 3 | #include "constants.h" 4 | 5 | IDI_ICON ICON DISCARDABLE "icon.ico" 6 | IDB_CHARS BITMAP DISCARDABLE "chars.bmp" 7 | IDB_KNOB BITMAP DISCARDABLE "knob.bmp" 8 | IDB_KNOB2 BITMAP DISCARDABLE "knob2.bmp" 9 | IDB_KNOB3 BITMAP DISCARDABLE "knob3.bmp" 10 | IDB_CHAVE BITMAP DISCARDABLE "key.bmp" 11 | IDB_FUNDO BITMAP DISCARDABLE "bg.bmp" 12 | IDB_BUTTONS BITMAP DISCARDABLE "buttons.bmp" 13 | IDB_OPS BITMAP DISCARDABLE "ops.bmp" 14 | 15 | VS_VERSION_INFO VERSIONINFO 16 | FILEVERSION OXFM_MAJOR_VERSION,OXFM_MINOR_VERSION,OXFM_PATCH_VERSION,0 17 | PRODUCTVERSION OXFM_MAJOR_VERSION,OXFM_MINOR_VERSION,OXFM_PATCH_VERSION,0 18 | FILEFLAGSMASK 0x3fL 19 | FILEFLAGS 0x0L 20 | FILEOS 0x40004L 21 | FILETYPE VFT_DLL 22 | FILESUBTYPE 0x0L 23 | BEGIN 24 | BLOCK "StringFileInfo" 25 | BEGIN 26 | BLOCK "040904E4" 27 | BEGIN 28 | VALUE "Comments", "http://www.oxesoft.com" 29 | VALUE "CompanyName", "Oxe Music Software" 30 | VALUE "FileDescription", "Oxe FM Synth VSTi" 31 | VALUE "FileVersion", VERSION_STR 32 | VALUE "InternalName", "oxevst" 33 | VALUE "LegalCopyright", "Copyright Daniel Moura, GNU GPL" 34 | VALUE "OriginalFilename", "oxevst.dll" 35 | VALUE "ProductName", "Oxe FM Synth" 36 | VALUE "ProductVersion", VERSION_STR 37 | END 38 | END 39 | BLOCK "VarFileInfo" 40 | BEGIN 41 | VALUE "Translation", 0x409, 1252 42 | END 43 | END 44 | --------------------------------------------------------------------------------