├── .gitignore ├── docs ├── eax-reverb-properties.pdf ├── standard-reverb-properties.pdf └── overview-of-systems.md ├── app_image_resources ├── binaural-audio-editor.png ├── create-home-data-dir.sh └── binaural-audio-editor.desktop ├── src ├── timeline-track-editor │ ├── resources │ │ └── read-this.txt │ ├── include │ │ ├── audio-stream-container.h │ │ ├── timeline-track-editor.h │ │ ├── track.h │ │ ├── timeline-frame.h │ │ ├── editor-graph.h │ │ ├── timeline-window.h │ │ ├── audio-graph.h │ │ ├── playback-controls.h │ │ ├── double-track.h │ │ ├── openalsoft-player.h │ │ ├── mono-audio-track.h │ │ ├── stereo-audio-track.h │ │ └── audio-track.h │ ├── parameters.h │ └── src │ │ ├── track.cpp │ │ ├── audio-stream-container.cpp │ │ ├── timeline-frame.cpp │ │ ├── timeline-window.cpp │ │ ├── double-track.cpp │ │ └── playback-controls.cpp ├── LoadSystem.cpp ├── SaveSystem.cpp ├── listener-external.cpp ├── HRTF-Test-Dialog.cpp ├── Change-HRTF-Dialog.cpp ├── setup-serial-dialog.cpp ├── soundproducer-track-manager.cpp ├── external-orientation-device-serial.cpp ├── soundproducer-registry.cpp ├── soundproducer.cpp ├── CreateSoundProducerDialog.cpp └── EditListenerDialog.cpp ├── CREDITS.txt ├── include ├── HRTF-Test-Dialog.h ├── listener-external.h ├── setup-serial-dialog.h ├── LoadSystem.h ├── Change-HRTF-Dialog.h ├── SaveSystem.h ├── EditListenerDialog.h ├── external-orientation-device-serial.h ├── XMLReader.h ├── CreateSoundProducerDialog.h ├── XMLCreator.h ├── EditMultipleSoundProducersDialog.h ├── EditMultipleEchoZonesDialog.h ├── echo-zone.h ├── SimpleSerial.h ├── CreateEchoZoneDialog.h ├── EditMultipleReverbZonesDialog.h ├── EditMultipleStandardReverbZonesDialog.h ├── soundproducer-track-manager.h ├── openalsoftaudioengine.h ├── CreateStandardReverbZoneDialog.h ├── soundproducer-registry.h ├── effect-zone.h ├── CreateEAXReverbZoneDialog.h ├── EditMultipleEAXReverbZonesDialog.h ├── effects-manager.h ├── soundproducer.h ├── listener-track.h ├── listener.h ├── soundproducer-track.h └── reverb-zone.h ├── External-Orientation-Setup.md ├── LICENSE.txt ├── .travis.yml ├── hardware-code └── bno055_abs_orientation │ └── bno055_abs_orientation.ino ├── CMakeLists.txt └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | release/ 3 | debug/ 4 | *.wav 5 | -------------------------------------------------------------------------------- /docs/eax-reverb-properties.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adct-the-experimenter/binaural-audio-editor/HEAD/docs/eax-reverb-properties.pdf -------------------------------------------------------------------------------- /docs/standard-reverb-properties.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adct-the-experimenter/binaural-audio-editor/HEAD/docs/standard-reverb-properties.pdf -------------------------------------------------------------------------------- /app_image_resources/binaural-audio-editor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adct-the-experimenter/binaural-audio-editor/HEAD/app_image_resources/binaural-audio-editor.png -------------------------------------------------------------------------------- /src/timeline-track-editor/resources/read-this.txt: -------------------------------------------------------------------------------- 1 | This is a directory with which to put inside stream.wav . stream.wav is a file created by the program to contain data that is to be edited and played. 2 | -------------------------------------------------------------------------------- /app_image_resources/create-home-data-dir.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [ -d '${HOME}/binaural-audio-editor/resources'] 4 | then 5 | echo "data directoy is in ${HOME}/binaural-audio-editor/resources." 6 | else 7 | echo "creating data directory in home directory..." 8 | mkdir -p ${HOME}/binaural-audio-editor/resources 9 | -------------------------------------------------------------------------------- /CREDITS.txt: -------------------------------------------------------------------------------- 1 | This project is dedicated to my parents Pablo Antonio Camacho Sr. and Darlene Camacho, for providing a good home and support. 2 | 3 | It is also dedicated to God and Jesus Christ. Thank you. 4 | 5 | 6 | Windows port Feedback and Design Feedback 7 | 8 | Matthew Kerswill 9 | 10 | Accessibility Features Feedback 11 | 12 | Marx Vergel Melencio 13 | -------------------------------------------------------------------------------- /app_image_resources/binaural-audio-editor.desktop: -------------------------------------------------------------------------------- 1 | 2 | [Desktop Entry] 3 | Name=Binaural Audio Editor 4 | StartupWMClass=Binaural-Audio-Editor 5 | Comment=Produce 3D audio 6 | GenericName=Audio Editor 7 | Exec=binaural-audio-editor 8 | Icon=binaural-audio-editor 9 | Type=Application 10 | Categories=Audio; 11 | MimeType=text/xml;application/xhtml+xml;application/xml; 12 | Keywords=Binaural;Audio;Editor; 13 | -------------------------------------------------------------------------------- /include/HRTF-Test-Dialog.h: -------------------------------------------------------------------------------- 1 | #ifndef _HRTF_TEST_DIALOG_H 2 | #define _HRTF_TEST_DIALOG_H 3 | 4 | #include 5 | #include 6 | 7 | 8 | #include //for wxTextCtrl 9 | 10 | 11 | #include "openalsoftaudioengine.h" //for loading buffer and creating source of sound producer 12 | 13 | class HRTFTestDialog : public wxDialog 14 | { 15 | 16 | public: 17 | HRTFTestDialog(const wxString& title, 18 | OpenAlSoftAudioEngine* audioEngine); 19 | 20 | 21 | void OnOk(wxCommandEvent& event ); 22 | 23 | void Exit(); 24 | 25 | enum 26 | { 27 | ID_OK = wxID_HIGHEST + 1, 28 | }; 29 | 30 | 31 | private: 32 | 33 | wxButton* okButton; 34 | 35 | wxTextCtrl* textBox; 36 | 37 | OpenAlSoftAudioEngine* ptrAudioEngine; 38 | 39 | void initPrivateVariables(); 40 | 41 | DECLARE_EVENT_TABLE() 42 | 43 | }; 44 | 45 | 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /include/listener-external.h: -------------------------------------------------------------------------------- 1 | #ifndef LISTENER_EXTERNAL_H 2 | #define LISTENER_EXTERNAL_H 3 | 4 | #include "external-orientation-device-serial.h" //for changing listener orientation with an external device 5 | #include "listener.h" 6 | 7 | 8 | //class to handle controlling listener with external device 9 | 10 | class ListenerExternal 11 | { 12 | public: 13 | 14 | ListenerExternal(Listener* thisListener); 15 | ~ListenerExternal(); 16 | 17 | ExternalOrientationDeviceSerial* GetExternalOrientationSerialDevicePtr(); 18 | void SetOrientationByExternalDevice(); 19 | 20 | void SetSerialPortPath(std::string port); 21 | std::string GetSerialPortPath(); 22 | 23 | private: 24 | ExternalOrientationDeviceSerial* m_ext_orientation_serial_device_ptr; 25 | Listener* m_listener_ptr; 26 | 27 | ExternalDeviceRepeatTimer* m_device_op_repeater; 28 | 29 | //path to serial port 30 | std::string serialPortPath; 31 | }; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /External-Orientation-Setup.md: -------------------------------------------------------------------------------- 1 | # To use IMU BNO055 sensor to control listener orientation. 2 | 3 | ## Arduino Instructions 4 | 1. Open Arduino IDE and install Adafruit BNO055 sensor library. https://github.com/adafruit/Adafruit_BNO055 5 | 2. Connect Arduino microcontroller to Adafruit BNO055 breakout board. 6 | 3. Connect USB cable to Arduino microcontroller. 7 | 4. For Linux, run sudo chmod a+rw /dev/ttyACM0 to allow serial port connection to binaural audio editor and Arudino IDE. 8 | 5. In Arduino IDE, open file hardware-code/bno055_abs_orientation/bno055_abs_orientation.ino 9 | 6. Upload the code to the Arduino. 10 | 7. Open binaural-audio-editor 11 | 8. Go to Listener->Setup Serial. 12 | - For Linux, type /dev/ttyACM0 into serial port text field and click Setup. Click Ok. 13 | 9. Go to Listener->Edit Listener 14 | 10. Check the External Device Orientation box. 15 | 11. The orientation will now change when sound is playing through sound producer track and it will be set by the physical BNO055 IMU sensor. 16 | -------------------------------------------------------------------------------- /include/setup-serial-dialog.h: -------------------------------------------------------------------------------- 1 | #ifndef SETUP_SERIAL_DIALOG_H 2 | #define SETUP_SERIAL_DIALOG_H 3 | 4 | #include 5 | 6 | 7 | #include //for wxFloatingPointValidator 8 | #include //for wxTextCtrl 9 | #include //for list box 10 | 11 | #include 12 | 13 | #include 14 | 15 | #include "listener-external.h" 16 | 17 | class SetupSerialDialog : public wxDialog 18 | { 19 | 20 | public: 21 | SetupSerialDialog(const wxString& title,ListenerExternal* listener_ext); 22 | 23 | 24 | void OnOk(wxCommandEvent& event ); 25 | 26 | void OnCancel(wxCommandEvent& event); 27 | 28 | void OnSetup(wxCommandEvent& event); 29 | 30 | void Exit(); 31 | 32 | 33 | private: 34 | 35 | wxButton* okButton; 36 | wxButton* cancelButton; 37 | wxButton* setupButton; 38 | 39 | 40 | wxTextCtrl* textFieldSerialPort; 41 | 42 | ListenerExternal* ptrListenerExternal; 43 | 44 | void initPrivateVariables(); 45 | 46 | void ChangeListenerAttributes(); 47 | 48 | }; 49 | 50 | 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /include/LoadSystem.h: -------------------------------------------------------------------------------- 1 | #ifndef LOAD_SYSTEM_H 2 | #define LOAD_SYSTEM_H 3 | 4 | #include 5 | 6 | #include "XMLReader.h" 7 | #include "effects-manager.h" 8 | 9 | 10 | class LoadSystem 11 | { 12 | public: 13 | LoadSystem(); 14 | ~LoadSystem(); 15 | 16 | //function used to load project 17 | void LoadProject(std::vector *sound_producer_save_data, 18 | std::vector *ptrSPTracksSaveDataVec, 19 | std::vector *echoZonesSaveData, 20 | std::vector *standardRevZonesSaveData, 21 | std::vector *eaxRevZonesSaveData, 22 | ListenerTrackSaveData& listener_track_data, 23 | ListenerSaveData& listener_save_data, 24 | std::string path); 25 | 26 | private: 27 | 28 | //xml file reader 29 | XMLReader xml_reader; 30 | 31 | //for sound producer tracks 32 | //std::vector tmp_DDXMaps; 33 | //std::vector tmp_DDYMaps; 34 | //std::vector tmp_DDZMaps; 35 | 36 | 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/LoadSystem.cpp: -------------------------------------------------------------------------------- 1 | #include "LoadSystem.h" 2 | 3 | LoadSystem::LoadSystem() 4 | { 5 | 6 | } 7 | 8 | LoadSystem::~LoadSystem() 9 | { 10 | 11 | } 12 | 13 | void LoadSystem::LoadProject(std::vector *sound_producer_save_data, 14 | std::vector *ptrSPTracksSaveDataVec, 15 | std::vector *echoZonesSaveData, 16 | std::vector *standardRevZonesSaveData, 17 | std::vector *eaxRevZonesSaveData, 18 | ListenerTrackSaveData& listener_track_data, 19 | ListenerSaveData& listener_save_data, 20 | std::string path 21 | ) 22 | { 23 | //read data from xml file and push into the sound producers, sound producer tracks, 24 | //and effect zones 25 | 26 | xml_reader.LoadDataFromXMLFile(sound_producer_save_data, 27 | ptrSPTracksSaveDataVec, 28 | echoZonesSaveData, 29 | standardRevZonesSaveData, 30 | eaxRevZonesSaveData, 31 | listener_track_data, 32 | listener_save_data, 33 | path); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/timeline-track-editor/include/audio-stream-container.h: -------------------------------------------------------------------------------- 1 | #ifndef AUDIO_STREAM_CONTAINER 2 | #define AUDIO_STREAM_CONTAINER 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class AudioStreamContainer 10 | { 11 | public: 12 | AudioStreamContainer(); 13 | 14 | void SetReferenceToInputAudioData(std::vector *input_audio_data); 15 | 16 | void ResizeAudioStream(size_t thisSize); 17 | size_t GetSize(); 18 | 19 | void SetPointerToDataAtThisSampleIndex(double* thisRef,size_t i); 20 | double* GetPointerToDataAtThisSampleIndex(size_t i); 21 | 22 | void CopyInputAudioDataToStream(); 23 | 24 | void WriteStreamContentsToFile(std::string filename, int format, int channels, int samplerate,int buffer_length); 25 | 26 | int GetFormat(); 27 | int GetChannels(); 28 | int GetSampleRate(); 29 | 30 | void ClearStreamDataStored(); 31 | void ClearDataInStreamFile(std::string filename); 32 | 33 | private: 34 | std::vector *input_audio_data_ptr; 35 | 36 | std::vector stream_audio_data; 37 | 38 | int m_format; 39 | int m_channels; 40 | int m_sample_rate; 41 | 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/timeline-track-editor/include/timeline-track-editor.h: -------------------------------------------------------------------------------- 1 | // wxWidgets "Hello world" Program 2 | // For compilers that support precompilation, includes "wx/wx.h". 3 | #include 4 | #ifndef WX_PRECOMP 5 | #include 6 | #endif 7 | 8 | #include "timeline-frame.h" 9 | 10 | #include "double-track.h" 11 | #include "stereo-audio-track.h" 12 | 13 | //override wxApp to initialize program 14 | class MyApp: public wxApp 15 | { 16 | public: 17 | virtual bool OnInit(); //initialize program 18 | 19 | void OnIdle(wxIdleEvent &event); 20 | }; 21 | 22 | //override wxFrame to make new custom window 23 | class MyFrame: public wxFrame 24 | { 25 | public: 26 | MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size); 27 | 28 | private: 29 | void OnHello(wxCommandEvent& event); 30 | void OnExit(wxCommandEvent& event); 31 | void OnAbout(wxCommandEvent& event); 32 | wxDECLARE_EVENT_TABLE(); 33 | 34 | //OpenAL Soft related parameters to play audio 35 | ALCdevice* audioDevice; 36 | ALCcontext* alContext; 37 | 38 | ALuint source; 39 | OpenALSoftPlayer* audioPlayer; 40 | }; 41 | 42 | //unique identifier to use to react to menu command 43 | enum 44 | { 45 | ID_Hello = 1 46 | }; 47 | 48 | -------------------------------------------------------------------------------- /include/Change-HRTF-Dialog.h: -------------------------------------------------------------------------------- 1 | #ifndef _CHANGE_HRTF_DIALOG_H 2 | #define _CHANGE_HRTF_DIALOG_H 3 | 4 | #include 5 | #include 6 | 7 | 8 | #include //for wxTextCtrl 9 | 10 | 11 | #include "openalsoftaudioengine.h" //for hrtf operations 12 | 13 | #include 14 | 15 | #include //for wxFloatingPointValidator 16 | #include //for wxTextCtrl 17 | #include //for list box 18 | 19 | #include 20 | 21 | class ChangeHRTFDialog : public wxDialog 22 | { 23 | 24 | public: 25 | ChangeHRTFDialog(const wxString& title, 26 | OpenAlSoftAudioEngine* audioEngine); 27 | 28 | 29 | 30 | void OnOk(wxCommandEvent& event ); 31 | 32 | void OnChange(wxCommandEvent& event); 33 | 34 | void Exit(); 35 | 36 | enum 37 | { 38 | ID_OK = wxID_HIGHEST + 1, 39 | ID_CHANGE, 40 | ID_LISTBOX 41 | }; 42 | 43 | 44 | private: 45 | std::vector hrtf_names; 46 | 47 | wxButton* okButton; 48 | 49 | wxButton* changeButton; 50 | 51 | OpenAlSoftAudioEngine* ptrAudioEngine; 52 | 53 | wxListBox* listbox; 54 | int selection_index; 55 | 56 | void initPrivateVariables(); 57 | 58 | void OnHRTFNameSelected(wxCommandEvent& event); 59 | 60 | DECLARE_EVENT_TABLE() 61 | 62 | }; 63 | 64 | 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /src/timeline-track-editor/parameters.h: -------------------------------------------------------------------------------- 1 | #ifndef PARAMETERS_H 2 | #define PARAMETERS_H 3 | 4 | #include 5 | 6 | enum 7 | { 8 | TRACK_WIDTH = 12000, // width,in pixels, of the track 9 | TRACK_HEIGHT = 140, //height,in pixels, of the track 10 | 11 | INITIAL_TIMELINE_WINDOW_WIDTH = 500, //width in pixels of timeline window 12 | INITIAL_TIMELINE_WINDOW_HEIGHT = 700, //height in pixels of timeline window 13 | 14 | 15 | TIME_START_VALUE = 0, //start value, in seconds, of ruler and track time 16 | TIME_END_VALUE = 600, //end value, in seconds, of ruler and track time 17 | TIME_RESOLUTION = 500, //resolution, in milliseconds, of playback timer and track timer. i.e. if TIME_RESOLUTION=0.1s, only move forward by 0.1s in playback 18 | 19 | REWIND_SPEED = 5, // how fast to rewind, moves REWIND_SPEED*TIME_RESOLUTION during rewind 20 | FAST_FORWARD_SPEED = 5, // how fast to fast forward, FAST_FORWARD_SPEED*TIME_RESOLUTION during fast forward 21 | 22 | TIME_TICK_NUM = 21, //number of ticks to display in ruler, make sure to include zero 23 | VERTICAL_LINE_HEIGHT_TIME = 400 //height,in pixels, of the vertical line showing current time position 24 | }; 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /include/SaveSystem.h: -------------------------------------------------------------------------------- 1 | #ifndef SAVE_SYSTEM_H 2 | #define SAVE_SYSTEM_H 3 | 4 | #include 5 | 6 | #include "XMLCreator.h" 7 | #include "effects-manager.h" 8 | 9 | 10 | class SaveSystem 11 | { 12 | public: 13 | SaveSystem(); 14 | ~SaveSystem(); 15 | 16 | //function used to save project data to already established save file 17 | void SaveProjectToSetFile(std::vector < std::unique_ptr > *sound_producer_vector_ptr, 18 | EffectsManager* effectsManagerPtr, 19 | ListenerTrack* listener_track_ptr, 20 | Listener* listener_ptr); 21 | 22 | //function to save project data to new file 23 | //overwrites member save file path 24 | void SaveAsNewProject(std::vector < std::unique_ptr > *sound_producer_vector_ptr, 25 | EffectsManager* effectsManagerPtr, 26 | ListenerTrack* listener_track_ptr, 27 | Listener* listener_ptr, 28 | std::string path); 29 | 30 | //function to set svae file path 31 | void SetSaveFilePath(std::string path); 32 | 33 | private: 34 | 35 | //xml file writer 36 | XMLCreator xml_creator; 37 | 38 | std::string m_saveFilePath; 39 | 40 | void SaveProject(std::vector < std::unique_ptr > *sound_producer_vector_ptr, 41 | EffectsManager* effectsManagerPtr, 42 | ListenerTrack* listener_track_ptr, 43 | Listener* listener_ptr, 44 | std::string path); 45 | }; 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /include/EditListenerDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef _EDIT_LISTENER_H 2 | #define _EDIT_LISTENER_H 3 | 4 | #include 5 | #include 6 | 7 | #include //for wxFloatingPointValidator 8 | #include //for wxTextCtrl 9 | #include //for list box 10 | 11 | #include 12 | 13 | #include "listener.h" 14 | 15 | class EditListenerDialog : public wxDialog 16 | { 17 | 18 | public: 19 | EditListenerDialog(const wxString& title, Listener* listener); 20 | 21 | 22 | void OnOk(wxCommandEvent& event ); 23 | 24 | void OnCancel(wxCommandEvent& event); 25 | 26 | void OnApply(wxCommandEvent& event); 27 | 28 | void OnBrowse(wxCommandEvent& event); 29 | 30 | void Exit(); 31 | 32 | enum 33 | { 34 | ID_OK = wxID_HIGHEST + 1, 35 | ID_APPLY, 36 | ID_CANCEL 37 | }; 38 | 39 | 40 | private: 41 | 42 | wxButton* okButton; 43 | wxButton* cancelButton; 44 | wxButton* applyButton; 45 | 46 | wxTextCtrl* textFieldX; 47 | wxTextCtrl* textFieldY; 48 | wxTextCtrl* textFieldZ; 49 | 50 | 51 | wxCheckBox* checkBoxFreeRoam; 52 | bool tempFreeRoamBool; 53 | void OnFreeRoamCheckBoxClicked(wxCommandEvent& event); 54 | 55 | wxCheckBox* checkBoxExternalDeviceOrientation; 56 | bool tempExternalDeviceOrientation; 57 | void OnExternalDeviceOrientationCheckBoxClicked(wxCommandEvent& event); 58 | 59 | Listener* ptrListener; 60 | 61 | void initPrivateVariables(); 62 | 63 | void ChangeListenerAttributes(); 64 | 65 | }; 66 | 67 | 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /src/timeline-track-editor/include/track.h: -------------------------------------------------------------------------------- 1 | #ifndef TRACK_H 2 | #define TRACK_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | #include "../parameters.h" 12 | 13 | class Track : public wxPanel 14 | { 15 | 16 | public: 17 | Track(const wxString& title); 18 | 19 | virtual void InitTrack(wxWindow* parent, std::vector *timeTickVector); 20 | 21 | virtual void OnPaint(wxPaintEvent& event); 22 | virtual void OnScroll(wxScrollEvent& event); 23 | virtual void OnSize(wxSizeEvent& event); 24 | 25 | void SetReferenceToCurrentTimeVariable(double* thisTimeVariable); 26 | void SetReferenceToTimeTickVector(std::vector *thisVector); 27 | 28 | void SetTitle(wxString thisTitle); 29 | wxString GetTitle(); 30 | 31 | std::vector *GetReferenceToTimeTickVector(); 32 | 33 | double GetCurrentTime(); 34 | 35 | //function to call in timer loop, variable to manipulate gets changed here 36 | virtual void FunctionToCallInPlayState() = 0; 37 | virtual void FunctionToCallInPauseState() = 0; 38 | virtual void FunctionToCallInRewindState() = 0; 39 | virtual void FunctionToCallInFastForwardState() = 0; 40 | virtual void FunctionToCallInNullState() = 0; 41 | 42 | private: 43 | 44 | wxWindow* m_parent; 45 | 46 | wxString m_title; //title of the track 47 | 48 | double* current_time_pos_pointer; 49 | std::vector *ptrToTimeTickVector; 50 | 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2019, Pablo Antonio Camacho Jr. 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /src/timeline-track-editor/include/timeline-frame.h: -------------------------------------------------------------------------------- 1 | #ifndef TIMELINE_FRAME_H 2 | #define TIMELINE_FRAME_H 3 | 4 | #include "playback-controls.h" 5 | #include "timeline-window.h" 6 | 7 | #include // std::function, std::negate 8 | 9 | // Frame that contains Timeline scrolling window and playback controls 10 | class TimelineFrame : public wxFrame 11 | { 12 | public: 13 | TimelineFrame(wxWindow *parent); 14 | ~TimelineFrame(); 15 | 16 | TimelineWindow* GetTimelineWindow(); 17 | 18 | PlaybackControls* GetPlaybackControlsReference(); 19 | 20 | //Track related functions 21 | void AddTrack(Track* thisTrack, int& space); 22 | 23 | void AddTrackFunctionToCallInTimerLoopPlayState(Track* thisTrack); 24 | void AddTrackFunctionToCallInTimerLoopPauseState(Track* thisTrack); 25 | void AddTrackFunctionToCallInTimerLoopRewindState(Track* thisTrack); 26 | void AddTrackFunctionToCallInTimerLoopFastForwardState(Track* thisTrack); 27 | void AddTrackFunctionToCallInTimerLoopNullState(Track* thisTrack); 28 | 29 | //Display related functions 30 | void AddSpacerBlock(int space); //function to add space between boxes containing Tracks or panels 31 | void AddText(wxString thisText, wxPoint thisPoint);//function to add text anywhere in the window 32 | void AddBoxSizer(wxSizer *sizer, int proportion=0, int flag=0, int border=0, wxObject *userData=nullptr); 33 | 34 | void OnClose(wxCloseEvent& evt); 35 | 36 | private: 37 | TimelineWindow* timelineWindowPtr; 38 | PlaybackTimer* timer; 39 | PlaybackControls* controls; 40 | 41 | DECLARE_EVENT_TABLE() 42 | 43 | }; 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /include/external-orientation-device-serial.h: -------------------------------------------------------------------------------- 1 | #ifndef EXTERNAL_ORIENTATION_DEVICE_SERIAL_H 2 | #define EXTERNAL_ORIENTATION_DEVICE_SERIAL_H 3 | 4 | 5 | #include "SimpleSerial.h" //for getting serial data 6 | #include //for splitting string 7 | #include //for using quaternion to change orientation 8 | 9 | #include 10 | 11 | #include 12 | 13 | #include "listener.h" 14 | 15 | 16 | class ExternalOrientationDeviceSerial 17 | { 18 | 19 | public: 20 | ExternalOrientationDeviceSerial(); 21 | ~ExternalOrientationDeviceSerial(); 22 | 23 | void InitSerialCommunication(std::string port,unsigned int baud_rate); 24 | 25 | void SetDeviceInitializedBool(bool status); 26 | bool GetDeviceInitializedBool(); 27 | 28 | void ReadOrientationParametersFromSerial(float* fx,float* fy, float* fz, 29 | float* ux, float* uy,float* uz); 30 | 31 | private: 32 | SimpleSerial* m_serial_ptr; 33 | bool deviceInitialized; 34 | 35 | //quaternions for intial forward vector and up vector directions 36 | boost::math::quaternion forward_vector_quaternion; 37 | boost::math::quaternion up_vector_quaternion; 38 | 39 | }; 40 | 41 | //class to use with mainframe 42 | class ExternalDeviceRepeatTimer : public wxTimer 43 | { 44 | public: 45 | ExternalDeviceRepeatTimer(ExternalOrientationDeviceSerial* device,Listener* thisListener); 46 | void Notify(); //action to take periodically after certain amount of time defined 47 | void start(); 48 | 49 | void FunctionToRepeat(); 50 | 51 | private: 52 | ExternalOrientationDeviceSerial* m_device; 53 | Listener* m_listener_ptr; 54 | bool reading_values; 55 | 56 | void SetReadingValuesBool(bool state); 57 | bool GetReadingValuesBool(); 58 | }; 59 | 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /src/SaveSystem.cpp: -------------------------------------------------------------------------------- 1 | #include "SaveSystem.h" 2 | 3 | SaveSystem::SaveSystem() 4 | { 5 | 6 | } 7 | 8 | SaveSystem::~SaveSystem() 9 | { 10 | 11 | } 12 | 13 | void SaveSystem::SaveProjectToSetFile(std::vector < std::unique_ptr > *sound_producer_vector_ptr, 14 | EffectsManager* effectsManagerPtr, 15 | ListenerTrack* listener_track_ptr, 16 | Listener* listener_ptr ) 17 | { 18 | SaveSystem::SaveProject(sound_producer_vector_ptr,effectsManagerPtr,listener_track_ptr,listener_ptr,m_saveFilePath); 19 | } 20 | 21 | void SaveSystem::SaveAsNewProject(std::vector < std::unique_ptr > *sound_producer_vector_ptr, 22 | EffectsManager* effectsManagerPtr, 23 | ListenerTrack* listener_track_ptr, 24 | Listener* listener_ptr, 25 | std::string path) 26 | { 27 | m_saveFilePath = path; 28 | SaveSystem::SaveProject(sound_producer_vector_ptr,effectsManagerPtr,listener_track_ptr,listener_ptr,m_saveFilePath); 29 | } 30 | 31 | void SaveSystem::SaveProject(std::vector < std::unique_ptr > *sound_producer_vector_ptr, 32 | EffectsManager* effectsManagerPtr, 33 | ListenerTrack* listener_track_ptr, 34 | Listener* listener_ptr, 35 | std::string path) 36 | { 37 | 38 | //for each specific effect zone type 39 | xml_creator.SaveDataToXMLFile(sound_producer_vector_ptr, 40 | effectsManagerPtr->GetReferenceToSoundProducerTracksVector(), 41 | &effectsManagerPtr->echo_zones_vector, 42 | &effectsManagerPtr->standard_reverb_zones_vector, 43 | &effectsManagerPtr->eax_reverb_zones_vector, 44 | listener_track_ptr, 45 | listener_ptr, 46 | path); 47 | } 48 | 49 | 50 | void SaveSystem::SetSaveFilePath(std::string path){m_saveFilePath = path;} 51 | -------------------------------------------------------------------------------- /src/listener-external.cpp: -------------------------------------------------------------------------------- 1 | // For compilers that support precompilation, includes "wx.h". 2 | #include "wx/wxprec.h" 3 | 4 | #ifdef __BORLANDC__ 5 | #pragma hdrstop 6 | #endif 7 | 8 | #ifdef WIN32 9 | #include 10 | #endif 11 | 12 | #ifndef WX_PRECOMP 13 | #include "wx/wx.h" 14 | #endif 15 | 16 | #include "listener-external.h" 17 | 18 | 19 | ListenerExternal::ListenerExternal(Listener* thisListener) 20 | { 21 | m_listener_ptr = thisListener; 22 | 23 | m_ext_orientation_serial_device_ptr = new ExternalOrientationDeviceSerial(); 24 | 25 | m_device_op_repeater = nullptr; 26 | //m_device_op_repeater = new ExternalDeviceRepeatTimer(m_ext_orientation_serial_device_ptr,m_listener_ptr); 27 | 28 | //m_device_op_repeater->start(); 29 | serialPortPath = ""; 30 | } 31 | 32 | ListenerExternal::~ListenerExternal() 33 | { 34 | if(m_ext_orientation_serial_device_ptr != nullptr) 35 | { 36 | delete m_ext_orientation_serial_device_ptr; 37 | } 38 | 39 | if(m_device_op_repeater != nullptr) 40 | { 41 | delete m_device_op_repeater; 42 | } 43 | } 44 | 45 | void ListenerExternal::SetOrientationByExternalDevice() 46 | { 47 | float fx,fy,fz,ux,uy,uz; 48 | 49 | m_ext_orientation_serial_device_ptr->ReadOrientationParametersFromSerial(&fx,&fy,&fz,&ux,&uy,&uz); 50 | 51 | std::cout << "fx:" << fx << ", fy:" << fy << " ,fz:" << fz << "\n, ux:" << ux << ", uy:" << uy << ", uz:" << uz << std::endl; 52 | 53 | m_listener_ptr->SetWholeOrientation(fx,fy,fz,ux,uy,uz); 54 | } 55 | 56 | ExternalOrientationDeviceSerial* ListenerExternal::GetExternalOrientationSerialDevicePtr() 57 | { 58 | return m_ext_orientation_serial_device_ptr; 59 | } 60 | 61 | void ListenerExternal::SetSerialPortPath(std::string port){serialPortPath = port;} 62 | std::string ListenerExternal::GetSerialPortPath(){return serialPortPath;} 63 | -------------------------------------------------------------------------------- /src/timeline-track-editor/src/track.cpp: -------------------------------------------------------------------------------- 1 | #include "track.h" 2 | 3 | Track::Track(const wxString& title) : wxPanel() 4 | { 5 | m_title = title; 6 | 7 | Connect(wxEVT_PAINT, wxPaintEventHandler(Track::OnPaint)); 8 | Connect(wxEVT_SIZE, wxSizeEventHandler(Track::OnSize)); 9 | 10 | current_time_pos_pointer = nullptr; 11 | ptrToTimeTickVector = nullptr; 12 | } 13 | 14 | 15 | void Track::SetReferenceToCurrentTimeVariable(double* thisTimeVariable){current_time_pos_pointer = thisTimeVariable;} 16 | void Track::SetReferenceToTimeTickVector(std::vector *thisVector){ptrToTimeTickVector = thisVector;} 17 | 18 | std::vector *Track::GetReferenceToTimeTickVector(){return ptrToTimeTickVector;} 19 | 20 | void Track::SetTitle(wxString thisTitle){m_title = thisTitle;} 21 | wxString Track::GetTitle(){return m_title;} 22 | 23 | void Track::InitTrack(wxWindow* parent, std::vector *timeTickVector) 24 | { 25 | m_parent = parent; 26 | 27 | ptrToTimeTickVector = timeTickVector; 28 | this->Create(parent, wxID_ANY, wxPoint(wxDefaultPosition.x,wxDefaultPosition.y + 50), wxSize(TRACK_WIDTH, TRACK_HEIGHT),wxTAB_TRAVERSAL,m_title); 29 | this->SetBackgroundColour( *wxLIGHT_GREY ); 30 | this->Show(); 31 | } 32 | 33 | void Track::OnSize(wxSizeEvent& event) 34 | { 35 | Refresh(); 36 | 37 | FitInside(); 38 | 39 | event.Skip(); 40 | } 41 | 42 | void Track::OnScroll(wxScrollEvent& event) 43 | { 44 | //std::cout << "Scroll called! \n"; 45 | Refresh(); //for wxDc onPaint stuff 46 | 47 | FitInside(); //for scroll and sizer 48 | 49 | event.Skip(); 50 | } 51 | 52 | 53 | void Track::OnPaint(wxPaintEvent& event) 54 | { 55 | //std::cout << "Current Time in Track:" << *current_time_pos_pointer << std::endl; 56 | event.Skip(); 57 | } 58 | 59 | double Track::GetCurrentTime(){return *current_time_pos_pointer;} 60 | 61 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | compiler: gcc 3 | sudo: require 4 | dist: xenial 5 | 6 | install: 7 | 8 | - sudo apt-get -y install build-essential debianutils automake gcc g++ make alsoft-conf openal-info libopenal-data libopenal-dev libopenscenegraph-dev libsndfile-dev libwxgtk3.0-dev libboost-dev libasio-dev libboost-date-time-dev libboost-system-dev libpugixml-dev 9 | 10 | script: 11 | - wget -c "https://github.com/kcat/openal-soft/archive/openal-soft-1.20.1.tar.gz" 12 | - tar -xzf openal-soft-1.20.1.tar.gz && cd openal-soft-openal-soft-1.20.1 && cd build && cmake -DALSOFT_UTILS=OFF -DALSOFT_NO_CONFIG_UTIL=OFF .. && make && sudo make install 13 | - cd ../.. 14 | - mkdir build 15 | - cd build 16 | - mkdir AppDir 17 | - cp ../app_image_resources/binaural-audio-editor.png ./AppDir 18 | - cp ../app_image_resources/binaural-audio-editor.desktop ./AppDir 19 | - cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DwxWidgets_CONFIG_EXECUTABLE=/usr/bin/wx-config -DDATAPATH=${HOME}/.binaural-audio-editor/resources/ 20 | - make -j$(nproc) 21 | - make install DESTDIR=AppDir 22 | - wget -c "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage" 23 | - chmod a+x linuxdeploy*.AppImage 24 | - ./linuxdeploy*.AppImage --appdir AppDir --icon-file ./AppDir/binaural-audio-editor.png --desktop-file ./AppDir/binaural-audio-editor.desktop --output appimage 25 | 26 | after_success: 27 | - find ./AppDir -executable -type f -exec ldd {} \; | grep " => /usr" | cut -d " " -f 2-3 | sort | uniq 28 | - wget -c "https://github.com/probonopd/uploadtool/raw/master/upload.sh" 29 | - chmod a+x upload.sh 30 | - bash ./upload.sh ./Binaural*.AppImage 31 | 32 | branches: 33 | except: 34 | - # Do not build tags that we create when we upload to GitHub Releases 35 | - /^(?i:continuous)$/ 36 | -------------------------------------------------------------------------------- /include/XMLReader.h: -------------------------------------------------------------------------------- 1 | #ifndef XML_READER_H 2 | #define XML_READER_H 3 | 4 | #include "pugixml.hpp" 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | #include "listener-track.h" 11 | #include "soundproducer.h" 12 | #include "soundproducer-track.h" 13 | #include "echo-zone.h" 14 | #include "reverb-zone.h" 15 | 16 | 17 | 18 | //class used to save data in binaural audio editor into a xml file 19 | 20 | class XMLReader 21 | { 22 | public: 23 | 24 | XMLReader(); 25 | ~XMLReader(); 26 | 27 | void LoadDataFromXMLFile(std::vector *sound_producer_save_data, 28 | std::vector *ptrSPTracksVec, 29 | std::vector *echoZonesSaveData, 30 | std::vector *standardRevZonesSaveData, 31 | std::vector *eaxRevZonesSaveData, 32 | ListenerTrackSaveData& listener_track_ptr, 33 | ListenerSaveData& listener_data, 34 | std::string path); 35 | 36 | private: 37 | 38 | void LoadData_SoundProducers(pugi::xml_node& root, std::vector *sound_producer_save_data); 39 | void LoadData_SoundProducerTracks(pugi::xml_node& root, 40 | std::vector *ptrSPTracksVec); 41 | void LoadData_EchoZones(pugi::xml_node& root,std::vector *echoZonesSaveData); 42 | void LoadData_StandardRevZones(pugi::xml_node& root,std::vector *standardRevZonesSaveData); 43 | void LoadData_EAXRevZones(pugi::xml_node& root,std::vector *eaxRevZonesSaveData); 44 | 45 | void LoadData_ListenerTrack(pugi::xml_node& root, ListenerTrackSaveData& listener_track_data); 46 | 47 | void LoadData_Listener(pugi::xml_node& root, ListenerSaveData& listener_data); 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /include/CreateSoundProducerDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef _CREATE_SOUND_PRODUCER_H 2 | #define _CREATE_SOUND_PRODUCER_H 3 | 4 | #include 5 | 6 | #include //for wxFloatingPointValidator 7 | #include //for wxTextCtrl 8 | 9 | #include 10 | 11 | #include "openalsoftaudioengine.h" //for loading buffer and creating source of sound producer 12 | 13 | class CreateSoundProducerDialog : public wxDialog 14 | { 15 | 16 | public: 17 | CreateSoundProducerDialog(const wxString& title, OpenAlSoftAudioEngine* audioEngine); 18 | 19 | 20 | void OnOk(wxCommandEvent& event ); 21 | 22 | void OnCancel(wxCommandEvent& event); 23 | 24 | void OnBrowse(wxCommandEvent& event); 25 | 26 | void Exit(); 27 | 28 | enum 29 | { 30 | ID_OK = wxID_HIGHEST + 1, 31 | ID_CANCEL, 32 | ID_BROWSE 33 | }; 34 | 35 | //function to return position of new sound producer object 36 | void getNewPosition(double& x, double& y, double& z); 37 | 38 | std::string getNewName(); 39 | 40 | std::string& getSoundFilePath(); 41 | 42 | ALuint& getBuffer(); 43 | 44 | bool OkClickedOn(); 45 | 46 | bool getFreeRoamBool(); 47 | 48 | private: 49 | wxButton* okButton; 50 | wxButton* cancelButton; 51 | wxButton* browseButton; 52 | 53 | wxTextCtrl* textFieldName; 54 | 55 | wxTextCtrl* textFieldX; 56 | wxTextCtrl* textFieldY; 57 | wxTextCtrl* textFieldZ; 58 | 59 | wxTextCtrl* textFieldSoundFilePath; 60 | 61 | wxCheckBox* checkBoxFreeRoam; 62 | bool tempFreeRoamBool; 63 | 64 | OpenAlSoftAudioEngine* ptrAudioEngine; 65 | 66 | std::string name; 67 | double xPosition; 68 | double yPosition; 69 | double zPosition; 70 | 71 | std::string soundFilePath; 72 | ALuint buffer; 73 | 74 | 75 | 76 | 77 | bool okClicked; //bool to indicate if ok button was clicked on 78 | 79 | void initPrivateVariables(); 80 | 81 | DECLARE_EVENT_TABLE() 82 | 83 | }; 84 | 85 | 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /hardware-code/bno055_abs_orientation/bno055_abs_orientation.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | Adafruit_BNO055 bno = Adafruit_BNO055(55); 7 | int displayVar; 8 | 9 | void setup(void) 10 | { 11 | Serial.begin(9600); 12 | 13 | 14 | /* Initialise the sensor */ 15 | if(!bno.begin()) 16 | { 17 | /* There was a problem detecting the BNO055 ... check your connections */ 18 | Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!"); 19 | while(1); 20 | } 21 | 22 | delay(1000); 23 | 24 | bno.setExtCrystalUse(true); 25 | 26 | displayVar = 0; 27 | } 28 | 29 | void loop(void) 30 | { 31 | // Request quaternion data from BNO055 32 | imu::Quaternion quat = bno.getQuat(); 33 | 34 | HandleSerial(displayVar); 35 | 36 | switch(displayVar) 37 | { 38 | case 0:{/*Display nothing */ break;} 39 | case 1:{Serial.println(quat.w(), 4); break;} 40 | case 2:{Serial.println(quat.x(), 4); break;} 41 | case 3:{Serial.println(quat.y(), 4); break;} 42 | case 4:{Serial.println(quat.z(), 4); break;} 43 | } 44 | 45 | // Pause before capturing new data 46 | delay(100); 47 | } 48 | 49 | void HandleSerial(int& var) 50 | { 51 | 52 | 53 | while (Serial.available() > 0) 54 | { 55 | char incomingCharacter = Serial.read(); 56 | 57 | switch (incomingCharacter) 58 | { 59 | //send out rotation quaternion w value 60 | case '!': 61 | { 62 | var = 1; 63 | break; 64 | } 65 | //send out rotation quaternion x value 66 | case '@': 67 | { 68 | var = 2; 69 | break; 70 | } 71 | //send out rotation quaternion y value 72 | case '#': 73 | { 74 | var = 3; 75 | break; 76 | } 77 | //send out rotation quaternion z value 78 | case '$': 79 | { 80 | var = 4; 81 | break; 82 | } 83 | case '%': 84 | { 85 | var = 0; 86 | break; 87 | } 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /include/XMLCreator.h: -------------------------------------------------------------------------------- 1 | #ifndef XMLCREATOR_H 2 | #define XMLCREATOR_H 3 | 4 | #include 5 | #include 6 | 7 | #include "listener-track.h" 8 | #include "soundproducer.h" 9 | #include "soundproducer-track.h" 10 | #include "echo-zone.h" 11 | #include "reverb-zone.h" 12 | 13 | #include "pugixml.hpp" 14 | #include 15 | 16 | //class used to save data in binaural audio editor into a xml file 17 | 18 | class XMLCreator 19 | { 20 | public: 21 | 22 | XMLCreator(); 23 | ~XMLCreator(); 24 | 25 | //function to save data to xml file 26 | void SaveDataToXMLFile(std::vector < std::unique_ptr > *sound_producer_vector_ptr, 27 | std::vector *ptrSPTracksVec, 28 | std::vector *echoZones, 29 | std::vector *standardRevZones, 30 | std::vector *eaxRevZones, 31 | ListenerTrack* listener_track, 32 | Listener* listener_ptr, 33 | std::string path); 34 | 35 | private: 36 | 37 | //function to save data from sound producer tracks 38 | void SaveDataXML_SPTracks(pugi::xml_node& root, 39 | std::vector *ptrSPTracksVec); 40 | 41 | //function to save data from effect zones to xml file 42 | void SaveDataXML_EffectZones(pugi::xml_node& root, 43 | std::vector *echoZones, 44 | std::vector *standardRevZones, 45 | std::vector *eaxRevZones); 46 | 47 | //function to save data from sound producers to xml file 48 | void SaveDataXML_SoundProducers(pugi::xml_node& root, 49 | std::vector < std::unique_ptr > *sound_producer_vector_ptr); 50 | 51 | //function to save data from listener track to xml file 52 | void SaveDataXML_ListenerTrack(pugi::xml_node& root, ListenerTrack* listener_track_ptr); 53 | 54 | //function to save data from listener to xml file 55 | void SaveDataXML_Listener(pugi::xml_node& root, Listener* listener_ptr); 56 | 57 | 58 | }; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /include/EditMultipleSoundProducersDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef _EDIT_MULTIPLE_SOUND_PRODUCERS_H 2 | #define _EDIT_MULTIPLE_SOUND_PRODUCERS_H 3 | 4 | #include 5 | #include 6 | 7 | #include //for wxFloatingPointValidator 8 | #include //for wxTextCtrl 9 | #include //for list box 10 | 11 | #include "soundproducer.h" 12 | 13 | #include "openalsoftaudioengine.h" //for loading buffer and creating source of sound producer 14 | 15 | class EditMultipleSoundProducersDialog : public wxDialog 16 | { 17 | 18 | public: 19 | EditMultipleSoundProducersDialog(const wxString& title, 20 | std::vector > *sound_producer_vector, 21 | OpenAlSoftAudioEngine* audioEngine); 22 | 23 | 24 | void OnOk(wxCommandEvent& event ); 25 | 26 | void OnCancel(wxCommandEvent& event); 27 | 28 | void onApply(wxCommandEvent& event); 29 | 30 | void OnBrowse(wxCommandEvent& event); 31 | 32 | void Exit(); 33 | 34 | enum 35 | { 36 | ID_OK = wxID_HIGHEST + 1, 37 | ID_APPLY, 38 | ID_CANCEL, 39 | ID_RENAME, 40 | ID_LISTBOX 41 | }; 42 | 43 | 44 | bool OkClickedOn(); 45 | 46 | private: 47 | 48 | std::vector > *sound_producer_vector_ref; //pointer to vector of sound producers to edit 49 | 50 | wxButton* okButton; 51 | wxButton* cancelButton; 52 | wxButton* applyButton; 53 | 54 | wxTextCtrl* textFieldX; 55 | wxTextCtrl* textFieldY; 56 | wxTextCtrl* textFieldZ; 57 | 58 | wxListBox* listbox; 59 | 60 | OpenAlSoftAudioEngine* ptrAudioEngine; 61 | wxTextCtrl* textFieldSoundFilePath; 62 | wxButton* browseButton; 63 | std::string soundFilePath; 64 | ALuint buffer; 65 | 66 | wxCheckBox* checkBoxFreeRoam; 67 | bool tempFreeRoamBool; 68 | 69 | void initPrivateVariables(); 70 | 71 | bool okClicked; //bool to indicate if ok button was clicked on 72 | 73 | void ChangeSoundProducerAttributes(); 74 | 75 | void SoundProducerSelectedInListBox(wxCommandEvent& event ); 76 | 77 | DECLARE_EVENT_TABLE() 78 | 79 | }; 80 | 81 | 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /src/timeline-track-editor/include/editor-graph.h: -------------------------------------------------------------------------------- 1 | #include "wx/wx.h" 2 | #include "wx/sizer.h" 3 | 4 | #include "../parameters.h" 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | typedef std::unordered_map DDMap; 13 | 14 | class EditorGraph : public wxPanel 15 | { 16 | 17 | public: 18 | EditorGraph(wxWindow* parent); 19 | 20 | template 21 | void mouseDownLeftClick(T& vertStart, T& vertEnd, T& vertRes, 22 | double& time, int& relMouseY, bool& legitValues); 23 | 24 | void mouseDownRightClick(double& time,bool& legitValue); 25 | 26 | template 27 | void render(wxDC& dc, std::vector *verticalAxisVector); 28 | 29 | void SetReferenceToTimeTickVector(std::vector *thisVector); 30 | 31 | //function to return vertical graph value at some time 32 | //if no value is at that time, then legitValue is false and 0 is returned 33 | int GetVerticalGraphValueAtThisTime(double& thisTime,bool& legitValue); 34 | 35 | template 36 | void PlacePointsFromThisMap(DDMap& thisMap,T& vertStart, T& vertEnd, T& vertRes); 37 | 38 | private: 39 | 40 | std::vector *timeTickVectorPtr; 41 | 42 | //std::vector graph_points; //holds points drawn on graph 43 | 44 | std::unordered_map map_time; //dictionary to keep track of which time values are occupied 45 | 46 | //function to place point on mouse event 47 | template 48 | void PlacePointByMouse(T& vertStart, T& vertEnd, T& vertRes, 49 | double& time, int& relMouseY, bool& legitValues); 50 | 51 | //function to remove existing point on mouse event 52 | void RemovePointByMouse(double& time,bool& legitValue); 53 | 54 | //function to draw graph_points on graph 55 | void DrawCurrentPointsOnGraph(wxDC& dc); 56 | 57 | //functions to draw axes 58 | void DrawHorizontalAxis(wxDC& dc); 59 | template 60 | void DrawVerticalAxis(wxDC& dc,std::vector *verticalAxisVector); 61 | 62 | }; 63 | -------------------------------------------------------------------------------- /include/EditMultipleEchoZonesDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef EDIT_MULTIPLE_ECHO_ZONES_DIALOG_H 2 | #define EDIT_MULTIPLE_ECHO_ZONES_DIALOG_H 3 | 4 | #include 5 | #include 6 | 7 | #include //for wxFloatingPointValidator 8 | #include //for wxTextCtrl 9 | #include //for list box 10 | 11 | #include "effects-manager.h" 12 | 13 | class EditMultipleEchoZonesDialog : public wxDialog 14 | { 15 | 16 | public: 17 | EditMultipleEchoZonesDialog(const wxString& title,EffectsManager* effects_manager); 18 | 19 | 20 | void OnOk(wxCommandEvent& event ); 21 | 22 | void OnCancel(wxCommandEvent& event); 23 | 24 | void OnApply(wxCommandEvent& event); 25 | 26 | void OnPreview(wxCommandEvent& event); 27 | 28 | void Exit(); 29 | 30 | 31 | private: 32 | 33 | EffectsManager* effects_manager_ptr; //pointer to vector of sound producers to edit 34 | 35 | EchoZoneProperties tempEchoProp; 36 | //ReverbEAXProperties tempEAXRevProp; 37 | 38 | std::string name; 39 | double xPosition; 40 | double yPosition; 41 | double zPosition; 42 | double width; 43 | 44 | wxButton* okButton; 45 | wxButton* cancelButton; 46 | wxButton* applyButton; 47 | wxButton* previewButton; 48 | 49 | int m_selection_index; 50 | 51 | wxListBox* listboxEchoZones; 52 | 53 | void initPrivateVariables(); 54 | 55 | void ChangeEchoZoneAttributes(); 56 | 57 | void EchoZoneSelectedInListBox(wxCommandEvent& event ); 58 | 59 | wxListBox* listboxSoundProducers; 60 | int spt_selection_index; 61 | 62 | void SoundProducerTrackSelectedInListBox(wxCommandEvent& event ); 63 | 64 | //text fields 65 | 66 | wxTextCtrl* textFieldX; 67 | wxTextCtrl* textFieldY; 68 | wxTextCtrl* textFieldZ; 69 | wxTextCtrl* textFieldWidth; 70 | 71 | 72 | 73 | //AL_ECHO_DELAY 74 | wxTextCtrl* textField_flDelay; 75 | //AL_ECHO_LRDELAY 76 | wxTextCtrl* textField_flLRDelay; 77 | //AL_ECHO_DAMPING 78 | wxTextCtrl* textField_flDamping; 79 | //AL_ECHO_FEEDBACK 80 | wxTextCtrl* textField_flFeedback; 81 | //AL_ECHO_SPREAD 82 | wxTextCtrl* textField_flSpread; 83 | 84 | }; 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /include/echo-zone.h: -------------------------------------------------------------------------------- 1 | #ifndef ECHO_ZONE_H 2 | #define ECHO_ZONE_H 3 | 4 | #include "effect-zone.h" 5 | 6 | struct EchoZoneProperties 7 | { 8 | //AL_ECHO_DELAY 9 | double flDelay; 10 | //AL_ECHO_LRDELAY 11 | double flLRDelay; 12 | //AL_ECHO_DAMPING 13 | double flDamping; 14 | //AL_ECHO_FEEDBACK 15 | double flFeedback; 16 | //AL_ECHO_SPREAD 17 | double flSpread; 18 | }; 19 | 20 | struct EchoZoneSaveData 21 | { 22 | //name 23 | std::string name; 24 | 25 | //position 26 | double x; 27 | double y; 28 | double z; 29 | 30 | //size 31 | double width; 32 | 33 | //properties 34 | 35 | EchoZoneProperties properties; 36 | 37 | }; 38 | 39 | class EchoZone : public EffectZone 40 | { 41 | public: 42 | EchoZone(); 43 | ~EchoZone(); 44 | 45 | 46 | //functions to initialize echo zones 47 | 48 | void InitEchoZone(std::string& thisName, 49 | double& x, double& y, double& z, double& width, 50 | EchoZoneProperties& properties); 51 | 52 | void InitEchoZoneWithGraphicalObject(std::string& thisName, 53 | double& x, double& y, double& z, double& width, 54 | EchoZoneProperties& properties); 55 | 56 | //changed from effect zone to implement save data 57 | void SetPositionX(double& x); 58 | void SetPositionY(double& y); 59 | void SetPositionZ(double& z); 60 | void ChangeWidth(double width); 61 | 62 | //function to change reverb properties 63 | void ChangeEchoZoneProperties(EchoZoneProperties& properties); 64 | 65 | EchoZoneSaveData GetEchoZoneSaveData(); 66 | 67 | EchoZoneProperties& GetEchoZoneProperties(); 68 | 69 | virtual ALuint* GetEffectPointer(); 70 | virtual ALuint* GetEffectsSlotPointer(); 71 | 72 | virtual ALuint GetEffect(); 73 | virtual ALuint GetEffectsSlot(); 74 | 75 | virtual void FreeEffects(); 76 | 77 | private: 78 | 79 | ALuint m_effect; 80 | ALuint m_slot; 81 | 82 | ALuint LoadStandardReverbEffect(const EFXEAXREVERBPROPERTIES *reverb); 83 | ALuint LoadEAXReverbEffect(const EFXEAXREVERBPROPERTIES *reverb); 84 | 85 | EchoZoneProperties m_echo_prop; 86 | 87 | ZoneColor echoZoneColor; 88 | 89 | EchoZoneSaveData m_saveData; 90 | }; 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /src/timeline-track-editor/include/timeline-window.h: -------------------------------------------------------------------------------- 1 | #ifndef TIMELINE_WINDOW_H 2 | #define TIMELINE_WINDOW_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | #include "track.h" 13 | 14 | #include "../parameters.h" 15 | 16 | class TimelineWindow : public wxScrolled 17 | { 18 | public: 19 | TimelineWindow(wxWindow *parent); 20 | 21 | void OnPaint(wxPaintEvent& event); 22 | void OnScroll(wxScrollEvent& event); 23 | void OnSize(wxSizeEvent& event); 24 | 25 | //Timeline related functions 26 | 27 | void SetCurrentTimePosition(double& thisTime); 28 | double GetCurrentTimePosition(); 29 | 30 | //Track related functions 31 | 32 | void AddTrack(Track* thisTrack, int& space); 33 | wxSlider* getSliderReference(); //for updating track time 34 | double* getPointerToCurrentTimeReference(); 35 | 36 | std::vector *GetTimeTickVector(); //use to draw time ticks in tracks 37 | 38 | //Display related functions 39 | 40 | void AddSpacerBlock(int space); //function to add space between boxes containing Tracks or panels 41 | void AddText(wxString thisText, wxPoint thisPoint);//function to add text anywhere in the window 42 | void AddBoxSizer(wxSizer *sizer, int proportion=0, int flag=0, int border=0, wxObject *userData=nullptr); 43 | 44 | private: 45 | 46 | wxWindow* m_parent; 47 | 48 | //main box that contains all elements and places them vertically 49 | wxBoxSizer* main_v_box; 50 | 51 | wxSlider *m_slider; 52 | int m_slider_value; 53 | 54 | std::vector m_time_num; // numbers to display on ruler 55 | int slider_start_x_pos; //pixel x position of slider set based on ticks 56 | 57 | void InitTimeline(); //function to initialize parameters for timeline 58 | 59 | void InitTimeVector(); //function to initialze m_time_num 60 | std::vector LinearSpacedArray(double a, double b, std::size_t N); 61 | 62 | double current_time_pos; //the current time that the vertical line shows 63 | }; 64 | 65 | 66 | const int ID_SLIDER = 100; 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /include/SimpleSerial.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: SimpleSerial.h 3 | * Author: Terraneo Federico 4 | * Distributed under the Boost Software License, Version 1.0. 5 | * 6 | * Created on September 10, 2009, 12:12 PM 7 | */ 8 | 9 | #ifndef _SIMPLESERIAL_H 10 | #define _SIMPLESERIAL_H 11 | 12 | #define UNICODE 13 | 14 | #include 15 | 16 | class SimpleSerial 17 | { 18 | public: 19 | /** 20 | * Constructor. 21 | * \param port device name, example "/dev/ttyUSB0" or "COM4" 22 | * \param baud_rate communication speed, example 9600 or 115200 23 | * \throws boost::system::system_error if cannot open the 24 | * serial device 25 | */ 26 | SimpleSerial(std::string port, unsigned int baud_rate) 27 | : io(), serial(io,port) 28 | { 29 | serial.set_option(boost::asio::serial_port_base::baud_rate(baud_rate)); 30 | } 31 | 32 | /** 33 | * Write a string to the serial device. 34 | * \param s string to write 35 | * \throws boost::system::system_error on failure 36 | */ 37 | void writeString(std::string s) 38 | { 39 | boost::asio::write(serial,boost::asio::buffer(s.c_str(),s.size())); 40 | } 41 | 42 | /** 43 | * Blocks until a line is received from the serial device. 44 | * Eventual '\n' or '\r\n' characters at the end of the string are removed. 45 | * \return a string containing the received line 46 | * \throws boost::system::system_error on failure 47 | */ 48 | std::string readLine() 49 | { 50 | //Reading data char by char, code is optimized for simplicity, not speed 51 | char c; 52 | std::string result; 53 | for(;;) 54 | { 55 | boost::asio::read(serial,boost::asio::buffer(&c,1)); 56 | switch(c) 57 | { 58 | case '\r': 59 | break; 60 | case '\n': 61 | return result; 62 | default: 63 | result+=c; 64 | } 65 | } 66 | } 67 | 68 | private: 69 | boost::asio::io_service io; 70 | boost::asio::serial_port serial; 71 | }; 72 | 73 | #endif /* _SIMPLESERIAL_H */ 74 | 75 | -------------------------------------------------------------------------------- /src/HRTF-Test-Dialog.cpp: -------------------------------------------------------------------------------- 1 | #include "HRTF-Test-Dialog.h" 2 | 3 | HRTFTestDialog::HRTFTestDialog(const wxString & title,OpenAlSoftAudioEngine* audioEngine) 4 | : wxDialog(NULL, -1, title, wxDefaultPosition, wxSize(500, 250), wxRESIZE_BORDER) 5 | { 6 | 7 | ptrAudioEngine = audioEngine; 8 | 9 | HRTFTestDialog::initPrivateVariables(); 10 | 11 | 12 | textBox = new wxTextCtrl(this,-1, "", wxPoint(95, 140), wxSize(300,300), 13 | wxTE_READONLY | wxTE_MULTILINE, wxDefaultValidator, 14 | wxT("")); 15 | textBox->Clear(); 16 | 17 | //Test HRTF and put test results in textBox 18 | ptrAudioEngine->TestHRTF(); 19 | 20 | wxString thisTestResult(ptrAudioEngine->getHRTFTestResult()); 21 | textBox->WriteText(thisTestResult); 22 | 23 | ptrAudioEngine->clear_testHRTFResults(); 24 | 25 | 26 | //initialize Ok and Cancel buttons 27 | okButton = new wxButton(this, HRTFTestDialog::ID_OK, wxT("Ok"), 28 | wxDefaultPosition, wxSize(70, 30) 29 | ); 30 | 31 | //make horizontal box to put ok and cancel buttons in 32 | wxBoxSizer *hboxBottom = new wxBoxSizer(wxHORIZONTAL); 33 | 34 | 35 | hboxBottom->Add(okButton, 0); 36 | 37 | //Make vertical box to put everything in 38 | wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL); 39 | 40 | //add panel of text fields in vertical box 41 | vbox->Add(textBox, 1, wxEXPAND | wxALL, 10); 42 | vbox->Add(hboxBottom, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, 10); 43 | 44 | SetSizerAndFit(vbox); 45 | 46 | //center and show elements in dialog 47 | Centre(); 48 | ShowModal(); 49 | 50 | //destroy when done showing 51 | Destroy(); 52 | } 53 | 54 | void HRTFTestDialog::initPrivateVariables() 55 | { 56 | textBox = nullptr; 57 | okButton = nullptr; 58 | } 59 | 60 | 61 | void HRTFTestDialog::OnOk(wxCommandEvent& event ) 62 | { 63 | HRTFTestDialog::Exit(); 64 | } 65 | 66 | 67 | void HRTFTestDialog::Exit() 68 | { 69 | if(okButton != nullptr){ delete okButton;} 70 | if(textBox != nullptr){delete textBox;} 71 | 72 | Close( true ); //close window 73 | } 74 | 75 | //Event table for main frame specific events 76 | BEGIN_EVENT_TABLE(HRTFTestDialog, wxDialog) 77 | EVT_BUTTON (ID_OK, HRTFTestDialog::OnOk) 78 | END_EVENT_TABLE() 79 | -------------------------------------------------------------------------------- /src/timeline-track-editor/include/audio-graph.h: -------------------------------------------------------------------------------- 1 | #include "wx/wx.h" 2 | #include "wx/sizer.h" 3 | 4 | #include "../parameters.h" 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | #include 14 | 15 | #include "audio-stream-container.h" 16 | 17 | //Class used to only plot audio waveforms 18 | 19 | class AudioGraph : public wxPanel 20 | { 21 | 22 | public: 23 | AudioGraph(wxWindow* parent); 24 | 25 | void mouseDownLeftClick(); 26 | 27 | void mouseDownRightClick(); 28 | 29 | void render(wxDC& dc, std::vector *verticalAxisVector); 30 | 31 | void SetReferenceToTimeTickVector(std::vector *thisVector); 32 | 33 | //function to return vertical graph value at some time 34 | //if no value is at that time, then legitValue is false and 0 is returned 35 | int GetVerticalGraphValueAtThisTime(double& thisTime,bool& legitValue); 36 | 37 | void PlotOneChannelStreamAudioDataToGraph(AudioStreamContainer* audio_data,int sample_rate, double& verticalStart, double& verticalEnd, double& verticalResolution); 38 | void PlotLeftChannelStreamAudioDataToGraph(AudioStreamContainer* audio_data,int sample_rate, double& verticalStart, double& verticalEnd, double& verticalResolution); 39 | void PlotRightChannelStreamAudioDataToGraph(AudioStreamContainer* audio_data,int sample_rate, double& verticalStart, double& verticalEnd, double& verticalResolution); 40 | 41 | void PlotAudioDataToGraph(std::vector *audio_data, int sample_rate, double& verticalStart, double& verticalEnd, double& verticalResolution); 42 | 43 | void ClearGraph(); 44 | 45 | private: 46 | 47 | std::vector *timeTickVectorPtr; 48 | 49 | std::vector max_graph_points; //holds points drawn on graph 50 | std::vector min_graph_points; 51 | 52 | //std::unordered_map ::iterator> map_time; //dictionary to keep track of which time values are occupied 53 | 54 | //function to draw graph_points on graph 55 | void DrawCurrentDataOnGraph(wxDC& dc); 56 | 57 | //functions to draw axes 58 | void DrawHorizontalAxis(wxDC& dc); 59 | 60 | void DrawVerticalAxis(wxDC& dc,std::vector *verticalAxisVector); 61 | 62 | }; 63 | 64 | -------------------------------------------------------------------------------- /include/CreateEchoZoneDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef CREATE_ECHO_ZONE_H 2 | #define CREATE_ECHO_ZONE_H 3 | 4 | #include 5 | 6 | #include //for wxFloatingPointValidator 7 | #include //for wxTextCtrl 8 | #include //for list box 9 | 10 | #include "effects-manager.h" 11 | 12 | 13 | 14 | class CreateEchoZoneDialog : public wxDialog 15 | { 16 | 17 | public: 18 | CreateEchoZoneDialog(const wxString& title,EffectsManager* effects_manager); 19 | 20 | 21 | void OnOk(wxCommandEvent& event ); 22 | 23 | void OnCancel(wxCommandEvent& event); 24 | 25 | void OnPreview(wxCommandEvent& event); 26 | 27 | void Exit(); 28 | 29 | 30 | //function to return position of new sound producer object 31 | void getNewPosition(double& x, double& y, double& z); 32 | 33 | std::string& getNewName(); 34 | 35 | double& getNewWidth(); 36 | 37 | EchoZoneProperties& getNewProperties(); 38 | 39 | enum 40 | { 41 | ID_OK = wxID_HIGHEST + 1, 42 | ID_PREVIEW, 43 | ID_APPLY, 44 | ID_CANCEL, 45 | ID_RENAME, 46 | ID_LISTBOX 47 | }; 48 | 49 | bool OkClicked(); 50 | 51 | private: 52 | EffectsManager* m_effects_manager_ptr; 53 | 54 | wxButton* okButton; 55 | wxButton* cancelButton; 56 | wxButton* previewButton; 57 | 58 | wxListBox* listboxSoundProducers; 59 | int spt_selection_index; 60 | 61 | //text fields 62 | wxTextCtrl* textFieldName; 63 | 64 | wxTextCtrl* textFieldX; 65 | wxTextCtrl* textFieldY; 66 | wxTextCtrl* textFieldZ; 67 | wxTextCtrl* textFieldWidth; 68 | 69 | 70 | //AL_ECHO_DELAY 71 | wxTextCtrl* textField_flDelay; 72 | //AL_ECHO_LRDELAY 73 | wxTextCtrl* textField_flLRDelay; 74 | //AL_ECHO_DAMPING 75 | wxTextCtrl* textField_flDamping; 76 | //AL_ECHO_FEEDBACK 77 | wxTextCtrl* textField_flFeedback; 78 | //AL_ECHO_SPREAD 79 | wxTextCtrl* textField_flSpread; 80 | 81 | //properties of zone to creates 82 | 83 | std::string name; 84 | double xPosition; 85 | double yPosition; 86 | double zPosition; 87 | double width; 88 | 89 | EchoZoneProperties properties; 90 | 91 | void initPrivateVariables(); 92 | 93 | bool okClicked; 94 | 95 | void SoundProducerTrackSelectedInListBox(wxCommandEvent& event ); 96 | 97 | 98 | 99 | }; 100 | 101 | 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /src/timeline-track-editor/src/audio-stream-container.cpp: -------------------------------------------------------------------------------- 1 | #include "audio-stream-container.h" 2 | 3 | #include 4 | #include 5 | 6 | 7 | AudioStreamContainer::AudioStreamContainer() 8 | { 9 | input_audio_data_ptr = nullptr; 10 | } 11 | 12 | void AudioStreamContainer::SetReferenceToInputAudioData(std::vector *input_audio_data){input_audio_data_ptr = input_audio_data;} 13 | 14 | 15 | void AudioStreamContainer::ResizeAudioStream(size_t thisSize){stream_audio_data.resize(thisSize);} 16 | size_t AudioStreamContainer::GetSize(){return stream_audio_data.size();} 17 | 18 | void AudioStreamContainer::SetPointerToDataAtThisSampleIndex(double* thisRef,size_t i) 19 | { 20 | stream_audio_data.at(i) = thisRef; 21 | } 22 | 23 | double* AudioStreamContainer::GetPointerToDataAtThisSampleIndex(size_t i) 24 | { 25 | return stream_audio_data.at(i); 26 | } 27 | 28 | void AudioStreamContainer::CopyInputAudioDataToStream() 29 | { 30 | if(input_audio_data_ptr != nullptr) 31 | { 32 | for(size_t i=0; i < input_audio_data_ptr->size(); i++) 33 | { 34 | double* thisRef = &(input_audio_data_ptr->at(i)); 35 | stream_audio_data[i] = thisRef; 36 | } 37 | } 38 | } 39 | 40 | void AudioStreamContainer::WriteStreamContentsToFile(std::string filename, int format, int channels, int sample_rate,int buffer_length) 41 | { 42 | SF_INFO sfinfo; 43 | sfinfo.channels = channels; m_channels = channels; 44 | sfinfo.samplerate = sample_rate; m_sample_rate = sample_rate; 45 | sfinfo.format = format; m_format = format; 46 | 47 | SNDFILE * outFile; 48 | 49 | // Open the stream file 50 | if (! ( outFile = sf_open (filename.c_str(), SFM_WRITE, &sfinfo))) 51 | { 52 | std::cout << "Not able to open stream file for writing" << outFile << std::endl; 53 | puts (sf_strerror (NULL)) ; 54 | return; 55 | } 56 | 57 | //write data 58 | size_t readSize = stream_audio_data.size(); 59 | sf_count_t write_count = 0; 60 | size_t count_buffer = 0; 61 | 62 | sf_seek(outFile, 0, SEEK_SET); 63 | write_count = sf_write_double(outFile, stream_audio_data.front(), readSize); 64 | 65 | sf_close(outFile); 66 | } 67 | 68 | int AudioStreamContainer::GetFormat(){return m_format;} 69 | int AudioStreamContainer::GetChannels(){return m_channels;} 70 | int AudioStreamContainer::GetSampleRate(){return m_sample_rate;} 71 | 72 | void AudioStreamContainer::ClearStreamDataStored() 73 | { 74 | //clear audio data stored 75 | stream_audio_data.clear(); 76 | } 77 | 78 | void AudioStreamContainer::ClearDataInStreamFile(std::string filename) 79 | { 80 | //clear audio data stored in file 81 | if( remove( filename.c_str() ) != 0 ) 82 | { 83 | std::cout << "\nError deleting file\n"; 84 | } 85 | else 86 | { 87 | std::cout << "\nFile successfully deleted.\n"; 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /src/timeline-track-editor/include/playback-controls.h: -------------------------------------------------------------------------------- 1 | #ifndef PLAYBACK_CONTROLS_H 2 | #define PLAYBACK_CONTROLS_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | #include // std::function, std::negate 12 | 13 | #include "timeline-window.h" 14 | 15 | class PlaybackControls : public wxWindow 16 | { 17 | public: 18 | PlaybackControls(wxWindow* parent); 19 | 20 | void RunPlaybackState(); 21 | void SetCurrentState(int state); 22 | int GetCurrentState(); 23 | void SetReferenceToTimelineWindow(TimelineWindow* thisTimeline); 24 | 25 | void SetCurrentTimePosition(double& thisTime); 26 | 27 | enum PlaybackState 28 | { 29 | STATE_NULL = 0, 30 | STATE_PLAY, 31 | STATE_PAUSE, 32 | STATE_REWIND, 33 | STATE_FAST_FORWARD 34 | }; 35 | 36 | //operations to carry out in playback 37 | void PlayOP(); 38 | void PauseOP(); 39 | void StopOP(); 40 | void RewindOP(); 41 | void FastForwardOP(); 42 | 43 | private: 44 | 45 | TimelineWindow* timelineWindowPtr; 46 | 47 | int current_state; 48 | 49 | 50 | 51 | wxButton *m_play_button; 52 | wxButton *m_pause_button; 53 | wxButton *m_stop_button; 54 | wxButton *m_rewind_button; 55 | wxButton *m_fast_forward_button; 56 | 57 | void Play(wxCommandEvent& event); 58 | void Pause(wxCommandEvent& event); 59 | void Stop(wxCommandEvent& event); 60 | void Rewind(wxCommandEvent& event); 61 | void FastForward(wxCommandEvent& event); 62 | 63 | double time_res_seconds; 64 | double time_rewind_seconds; 65 | double time_fast_forward_seconds; 66 | }; 67 | 68 | //class to use with mainframe 69 | class PlaybackTimer : public wxTimer 70 | { 71 | public: 72 | PlaybackTimer(PlaybackControls* controls); 73 | void Notify(); //action to take periodically after certain amount of time defined 74 | void start(); 75 | 76 | void AddFunctionToTimerLoopPlayState( std::function < void() > thisFunction); 77 | void AddFunctionToTimerLoopPauseState( std::function < void() > thisFunction); 78 | void AddFunctionToTimerLoopRewindState( std::function < void() > thisFunction); 79 | void AddFunctionToTimerLoopFastForwardState( std::function < void() > thisFunction); 80 | void AddFunctionToTimerLoopNullState( std::function < void() > thisFunction); 81 | 82 | private: 83 | PlaybackControls* m_controls; 84 | //vector of functions to call everytim Notify is called 85 | std::vector < std::function < void() > > functionsPlayState; 86 | std::vector < std::function < void() > > functionsPauseState; 87 | std::vector < std::function < void() > > functionsRewindState; 88 | std::vector < std::function < void() > > functionsFastForwardState; 89 | std::vector < std::function < void() > > functionsNullState; 90 | 91 | 92 | }; 93 | 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /src/timeline-track-editor/include/double-track.h: -------------------------------------------------------------------------------- 1 | #ifndef DOUBLE_TRACK_H 2 | #define DOUBLE_TRACK_H 3 | 4 | #include "track.h" 5 | #include "editor-graph.h" 6 | 7 | #include // std::function, std::negate 8 | #include "playback-controls.h" 9 | 10 | typedef std::unordered_map DDMap; 11 | 12 | class DoubleTrack : public Track 13 | { 14 | 15 | public: 16 | DoubleTrack(const wxString& title); 17 | 18 | virtual void InitTrack(wxWindow* parent, std::vector *timeTickVector); 19 | 20 | //function to set bounds for variable to change as well as number of ticks to draw 21 | virtual void SetupAxisForVariable(double& start, double& end, double& resolution, int& numTick); 22 | 23 | virtual void OnPaint(wxPaintEvent& event); 24 | virtual void OnScroll(wxScrollEvent& event); 25 | virtual void OnSize(wxSizeEvent& event); 26 | 27 | virtual void OnLeftMouseClick(wxMouseEvent& event); 28 | virtual void OnRightMouseClick(wxCommandEvent& event); 29 | 30 | void SetReferenceToCurrentTimeVariable(double* thisTimeVariable); 31 | 32 | void SetReferenceToTimeTickVector(std::vector *thisVector); 33 | std::vector *GetReferenceToTimeTickVector(); 34 | 35 | void SetReferenceToPlaybackControls(PlaybackControls* controls); 36 | PlaybackControls* GetReferenceToPlaybackControls(); 37 | 38 | void SetTitle(wxString thisTitle); 39 | wxString GetTitle(); 40 | 41 | double GetCurrentTime(); 42 | 43 | void SetReferenceToVarToManipulate(double* thisVar); 44 | 45 | virtual void FunctionToCallInPlayState(); 46 | virtual void FunctionToCallInPauseState(); 47 | virtual void FunctionToCallInRewindState(); 48 | virtual void FunctionToCallInFastForwardState(); 49 | virtual void FunctionToCallInNullState(); 50 | 51 | void SetFunctionToCallAfterVariableChange(std::function < void() > thisFunction); 52 | 53 | void render(wxDC& dc); 54 | void logic_left_click(); 55 | void logic_right_click(); 56 | 57 | DDMap* GetPointerToTimeValueMap(); 58 | 59 | void LoadDataFromThisTimeValueMap(DDMap& map); 60 | 61 | private: 62 | 63 | double* varToManipulatePtr; 64 | 65 | double verticalStart; //vertical axis start 66 | double verticalEnd; //vertical axis end 67 | double verticalResolution; 68 | int verticalNumTicks; //number of tick marks in vertical axis 69 | 70 | std::vector m_vertical_var_num; 71 | void InitVerticalAxis(); 72 | std::vector LinearSpacedArray(double a, double b, std::size_t N); 73 | 74 | EditorGraph* graphEditor; 75 | 76 | //2d map to hold output at certain time, for quick reading 77 | DDMap map_time_output; 78 | 79 | std::function < void() > func_after_var_change; 80 | 81 | PlaybackControls* playbackControlsPtr; 82 | 83 | }; 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /include/EditMultipleReverbZonesDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef EDIT_MULTIPLE_EAX_REVERB_ZONES_DIALOG_H 2 | #define EDIT_MULTIPLE_EAX_REVERB_ZONES_DIALOG_H 3 | 4 | #include 5 | #include 6 | 7 | #include //for wxFloatingPointValidator 8 | #include //for wxTextCtrl 9 | #include //for list box 10 | 11 | #include "effects-manager.h" 12 | 13 | class EditMultipleEAXReverbZonesDialog : public wxDialog 14 | { 15 | 16 | public: 17 | EditMultipleEAXReverbZonesDialog(const wxString& title,EffectsManager* effects_manager); 18 | 19 | 20 | void OnOk(wxCommandEvent& event ); 21 | 22 | void OnCancel(wxCommandEvent& event); 23 | 24 | void OnApply(wxCommandEvent& event); 25 | 26 | void OnPreview(wxCommandEvent& event); 27 | 28 | void Exit(); 29 | 30 | 31 | private: 32 | 33 | EffectsManager* effects_manager_ptr; //pointer to vector of sound producers to edit 34 | 35 | //ReverbStandardProperties tempStandardRevProp; 36 | ReverbEAXProperties tempEAXRevProp; 37 | 38 | std::string name; 39 | double xPosition; 40 | double yPosition; 41 | double zPosition; 42 | double width; 43 | 44 | wxButton* okButton; 45 | wxButton* cancelButton; 46 | wxButton* applyButton; 47 | wxButton* previewButton; 48 | 49 | int m_selection_index; 50 | 51 | wxListBox* listboxReverbZones; 52 | 53 | void initPrivateVariables(); 54 | 55 | void ChangeReverbZoneAttributes(); 56 | 57 | void ReverbZoneSelectedInListBox(wxCommandEvent& event ); 58 | 59 | wxListBox* listboxSoundProducers; 60 | int spt_selection_index; 61 | 62 | void SoundProducerTrackSelectedInListBox(wxCommandEvent& event ); 63 | 64 | //text fields 65 | wxTextCtrl* textFieldName; 66 | 67 | wxTextCtrl* textFieldX; 68 | wxTextCtrl* textFieldY; 69 | wxTextCtrl* textFieldZ; 70 | wxTextCtrl* textFieldWidth; 71 | 72 | 73 | 74 | //AL_REVERB_DENSITY, 75 | wxTextCtrl* textField_flDensity; 76 | //AL_REVERB_DIFFUSION, 77 | wxTextCtrl* textField_flDiffusion; 78 | //AL_REVERB_GAIN, 79 | wxTextCtrl* textField_flGain; 80 | //AL_REVERB_GAINHF, 81 | wxTextCtrl* textField_flGainHF; 82 | //AL_REVERB_DECAY_TIME, 83 | wxTextCtrl* textField_flDecayTime; 84 | //AL_REVERB_DECAY_HFRATIO, 85 | wxTextCtrl* textField_flDecayHFRatio; 86 | //AL_REVERB_REFLECTIONS_GAIN, 87 | wxTextCtrl* textField_flReflectionsGain; 88 | //AL_REVERB_REFLECTIONS_DELAY, 89 | wxTextCtrl* textField_flReflectionsDelay; 90 | //AL_REVERB_LATE_REVERB_GAIN, 91 | wxTextCtrl* textField_flLateReverbGain; 92 | //AL_REVERB_LATE_REVERB_DELAY, 93 | wxTextCtrl* textField_flLateReverbDelay; 94 | //AL_REVERB_AIR_ABSORPTION_GAINHF, 95 | wxTextCtrl* textField_flAirAbsorptionGainHF; 96 | //AL_REVERB_ROOM_ROLLOFF_FACTOR, 97 | wxTextCtrl* textField_flRoomRolloffFactor; 98 | 99 | }; 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /include/EditMultipleStandardReverbZonesDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef EDIT_MULTIPLE_STANDARD_REVERB_ZONES_DIALOG_H 2 | #define EDIT_MULTIPLE_STANDARD_REVERB_ZONES_DIALOG_H 3 | 4 | #include 5 | #include 6 | 7 | #include //for wxFloatingPointValidator 8 | #include //for wxTextCtrl 9 | #include //for list box 10 | 11 | #include "effects-manager.h" 12 | 13 | class EditMultipleStandardReverbZonesDialog : public wxDialog 14 | { 15 | 16 | public: 17 | EditMultipleStandardReverbZonesDialog(const wxString& title,EffectsManager* effects_manager); 18 | 19 | 20 | void OnOk(wxCommandEvent& event ); 21 | 22 | void OnCancel(wxCommandEvent& event); 23 | 24 | void OnApply(wxCommandEvent& event); 25 | 26 | void OnPreview(wxCommandEvent& event); 27 | 28 | void Exit(); 29 | 30 | 31 | private: 32 | 33 | EffectsManager* effects_manager_ptr; //pointer to vector of sound producers to edit 34 | 35 | ReverbStandardProperties tempStandardRevProp; 36 | //ReverbEAXProperties tempEAXRevProp; 37 | 38 | std::string name; 39 | double xPosition; 40 | double yPosition; 41 | double zPosition; 42 | double width; 43 | 44 | wxButton* okButton; 45 | wxButton* cancelButton; 46 | wxButton* applyButton; 47 | wxButton* previewButton; 48 | 49 | int m_selection_index; 50 | 51 | wxListBox* listboxReverbZones; 52 | 53 | void initPrivateVariables(); 54 | 55 | void ChangeReverbZoneAttributes(); 56 | 57 | void ReverbZoneSelectedInListBox(wxCommandEvent& event ); 58 | 59 | wxListBox* listboxSoundProducers; 60 | int spt_selection_index; 61 | 62 | void SoundProducerTrackSelectedInListBox(wxCommandEvent& event ); 63 | 64 | //text fields 65 | wxTextCtrl* textFieldName; 66 | 67 | wxTextCtrl* textFieldX; 68 | wxTextCtrl* textFieldY; 69 | wxTextCtrl* textFieldZ; 70 | wxTextCtrl* textFieldWidth; 71 | 72 | 73 | 74 | //AL_REVERB_DENSITY, 75 | wxTextCtrl* textField_flDensity; 76 | //AL_REVERB_DIFFUSION, 77 | wxTextCtrl* textField_flDiffusion; 78 | //AL_REVERB_GAIN, 79 | wxTextCtrl* textField_flGain; 80 | //AL_REVERB_GAINHF, 81 | wxTextCtrl* textField_flGainHF; 82 | //AL_REVERB_DECAY_TIME, 83 | wxTextCtrl* textField_flDecayTime; 84 | //AL_REVERB_DECAY_HFRATIO, 85 | wxTextCtrl* textField_flDecayHFRatio; 86 | //AL_REVERB_REFLECTIONS_GAIN, 87 | wxTextCtrl* textField_flReflectionsGain; 88 | //AL_REVERB_REFLECTIONS_DELAY, 89 | wxTextCtrl* textField_flReflectionsDelay; 90 | //AL_REVERB_LATE_REVERB_GAIN, 91 | wxTextCtrl* textField_flLateReverbGain; 92 | //AL_REVERB_LATE_REVERB_DELAY, 93 | wxTextCtrl* textField_flLateReverbDelay; 94 | //AL_REVERB_AIR_ABSORPTION_GAINHF, 95 | wxTextCtrl* textField_flAirAbsorptionGainHF; 96 | //AL_REVERB_ROOM_ROLLOFF_FACTOR, 97 | wxTextCtrl* textField_flRoomRolloffFactor; 98 | 99 | }; 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /include/soundproducer-track-manager.h: -------------------------------------------------------------------------------- 1 | #ifndef SOUNDPRODUCER_TRACK_MANAGER_H 2 | #define SOUNDPRODUCER_TRACK_MANAGER_H 3 | 4 | #include 5 | 6 | #include "soundproducer-track.h" 7 | 8 | #include "soundproducer-registry.h" 9 | 10 | //class to manipulate x,y z position of sound producer 11 | class SoundProducerTrackManager : public Track 12 | { 13 | public: 14 | SoundProducerTrackManager(const wxString& title,ALCdevice* thisAudioDevice,ALCcontext* thisAudioContext); 15 | ~SoundProducerTrackManager(); 16 | 17 | //functions to set reference to audio device and audio context to use for player 18 | void SetReferenceToAudioDevice(ALCdevice* thisAudioDevice); 19 | void SetReferenceToAudioContext(ALCcontext* thisAudioContext); 20 | 21 | void SetReferenceToSoundProducerTrackVector(std::vector *thisTrackVec); 22 | void AddSourceOfLastTrackToSoundProducerTrackManager(); 23 | void RemoveSourceOfLastTrackFromSoundProducerTrackManager(); 24 | 25 | //Functions inherited from Track 26 | void SetReferenceToCurrentTimeVariable(double* thisTimeVariable); 27 | double GetCurrentTime(); 28 | 29 | 30 | //function to call in timer loop, variable to manipulate gets changed here 31 | virtual void FunctionToCallInPlayState(); 32 | virtual void FunctionToCallInPauseState(); 33 | virtual void FunctionToCallInRewindState(); 34 | virtual void FunctionToCallInFastForwardState(); 35 | virtual void FunctionToCallInNullState(); 36 | 37 | //function to return status of sound being played 38 | bool IsSoundBeingPlayed(); 39 | 40 | //function to play a track by its index in the soundproducers vector 41 | void PlayThisTrackFromSoundProducerTrackVector(int& index); 42 | 43 | //function to pause a track by its index in the soundproducers vector 44 | void PauseThisTrackFromSoundProducerTrackVector(int& index); 45 | 46 | //funtion to stop a track by its index in the soundproducers vector 47 | void StopThisTrackFromSoundProducerTrackVector(int& index); 48 | 49 | //function for browsing audio for last soundproducer track created 50 | void BrowseAudioForThisSoundProducer(SoundProducer* lastProducer); 51 | 52 | //allow effects manager to be a friend so that it can access 53 | //sources to add effects to them 54 | friend class EffectsManager; 55 | 56 | private: 57 | 58 | //pointer to vector containing pointers to sound producer tracks 59 | std::vector *soundProducerTracks_vec; 60 | 61 | //vector to contain pointers to sound producer track sources 62 | std::vector soundproducertracks_sources_vector; 63 | 64 | OpenALSoftPlayer* audioPlayer; 65 | 66 | ALCdevice* audioDevicePtr; //pointer to audio device to be used 67 | ALCcontext* alContextPtr; //pointer to context of where audio is played 68 | 69 | bool soundPlaying; 70 | void SetSoundPlayingBool(bool status); 71 | 72 | }; 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /include/openalsoftaudioengine.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENALSOFTAUDIOENGINE_H 2 | #define OPENALSOFTAUDIOENGINE_H 3 | 4 | #include 5 | #include 6 | 7 | #include "time.h" 8 | 9 | #include "AL/al.h" //header for OpenAL Soft 10 | #include "AL/alc.h" //header for OpenAL Soft 11 | #include "AL/alext.h" //header for OpenAL Soft 12 | 13 | 14 | #include "sndfile.h" 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include "listener.h" 23 | 24 | /* This will be the length of the buffer used to hold frames while 25 | ** we process them. 26 | */ 27 | #define BUFFER_LEN 1024 28 | 29 | /* libsndfile can handle more than 6 channels but we'll restrict it to 2. */ 30 | #define MAX_CHANNELS 2 31 | 32 | 33 | //class inherits from QQMLPropertValue 34 | class OpenAlSoftAudioEngine 35 | { 36 | 37 | 38 | public: 39 | 40 | OpenAlSoftAudioEngine(); 41 | ~OpenAlSoftAudioEngine(); 42 | 43 | //function to initialize openAl Soft 44 | 45 | bool initOpenALSoft(); 46 | 47 | //function to clean up openAL Soft initialization 48 | void close_openALSoft(); 49 | 50 | ALCdevice* GetReferenceToAudioDevice(); 51 | ALCcontext* GetReferenceToAudioContext(); 52 | 53 | //HRTF 54 | //functions to perform tests for HRTF support 55 | void TestHRTF(); 56 | std::string getHRTFTestResult(); 57 | void clear_testHRTFResults(); 58 | 59 | void GetAvailableHRTFNames(std::vector *names_vector); 60 | std::string GetCurrentHRTFSelected(); 61 | 62 | void SelectThisHRTFByIndex(int& index,std::string& message); 63 | 64 | //Sound Playback Related Functions 65 | 66 | //loading buffer 67 | void loadSound(ALuint* buffer,const std::string& filename); //function to take in file path to sound file and load buffer info to ALuint buffer 68 | std::string getLoadSoundResult();//function to return load sound results string 69 | void clear_LoadSoundResults(); 70 | 71 | //Creating source to play sound 72 | void createSource(ALuint* buffer,ALuint* source); 73 | 74 | void playSound(ALuint* source); 75 | 76 | private: 77 | 78 | //OpenAL Soft sound setup variables 79 | ALCdevice* gAudioDevice; //audio device to be used 80 | ALCcontext* alContext; //context of where audio is played 81 | 82 | 83 | //******************************************************** 84 | //******************** Testing *************************** 85 | //******************************************************** 86 | 87 | //error flag variable to test if there is error anywhere regarding OpenAL Soft. 88 | ALenum test_error_flag; 89 | void error_check(std::string location_str); 90 | 91 | std::string loadSound_Results; //string variable to write results of loadSound to 92 | std::string testHRTF_Results; //string variable to write results of HRTF test to 93 | 94 | }; 95 | 96 | #endif // OPENALSOFTAUDIOENGINE_H 97 | -------------------------------------------------------------------------------- /include/CreateStandardReverbZoneDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef CREATE_STANDARD_REVERB_ZONE_H 2 | #define CREATE_STANDARD_REVERB_ZONE_H 3 | 4 | #include 5 | 6 | #include //for wxFloatingPointValidator 7 | #include //for wxTextCtrl 8 | #include //for list box 9 | 10 | #include "effects-manager.h" 11 | 12 | 13 | 14 | class CreateStandardReverbZoneDialog : public wxDialog 15 | { 16 | 17 | public: 18 | CreateStandardReverbZoneDialog(const wxString& title,EffectsManager* effects_manager); 19 | 20 | 21 | void OnOk(wxCommandEvent& event ); 22 | 23 | void OnCancel(wxCommandEvent& event); 24 | 25 | void OnPreview(wxCommandEvent& event); 26 | 27 | void Exit(); 28 | 29 | 30 | //function to return position of new sound producer object 31 | void getNewPosition(double& x, double& y, double& z); 32 | 33 | std::string& getNewName(); 34 | 35 | double& getNewWidth(); 36 | 37 | ReverbStandardProperties& getNewProperties(); 38 | 39 | enum 40 | { 41 | ID_OK = wxID_HIGHEST + 1, 42 | ID_PREVIEW, 43 | ID_APPLY, 44 | ID_CANCEL, 45 | ID_RENAME, 46 | ID_LISTBOX 47 | }; 48 | 49 | bool OkClicked(); 50 | 51 | private: 52 | EffectsManager* m_effects_manager_ptr; 53 | 54 | wxButton* okButton; 55 | wxButton* cancelButton; 56 | wxButton* previewButton; 57 | 58 | wxListBox* listboxSoundProducers; 59 | int spt_selection_index; 60 | 61 | //text fields 62 | wxTextCtrl* textFieldName; 63 | 64 | wxTextCtrl* textFieldX; 65 | wxTextCtrl* textFieldY; 66 | wxTextCtrl* textFieldZ; 67 | wxTextCtrl* textFieldWidth; 68 | 69 | //AL_REVERB_DENSITY, 70 | wxTextCtrl* textField_flDensity; 71 | //AL_REVERB_DIFFUSION, 72 | wxTextCtrl* textField_flDiffusion; 73 | //AL_REVERB_GAIN, 74 | wxTextCtrl* textField_flGain; 75 | //AL_REVERB_GAINHF, 76 | wxTextCtrl* textField_flGainHF; 77 | //AL_REVERB_DECAY_TIME, 78 | wxTextCtrl* textField_flDecayTime; 79 | //AL_REVERB_DECAY_HFRATIO, 80 | wxTextCtrl* textField_flDecayHFRatio; 81 | //AL_REVERB_REFLECTIONS_GAIN, 82 | wxTextCtrl* textField_flReflectionsGain; 83 | //AL_REVERB_REFLECTIONS_DELAY, 84 | wxTextCtrl* textField_flReflectionsDelay; 85 | //AL_REVERB_LATE_REVERB_GAIN, 86 | wxTextCtrl* textField_flLateReverbGain; 87 | //AL_REVERB_LATE_REVERB_DELAY, 88 | wxTextCtrl* textField_flLateReverbDelay; 89 | //AL_REVERB_AIR_ABSORPTION_GAINHF, 90 | wxTextCtrl* textField_flAirAbsorptionGainHF; 91 | //AL_REVERB_ROOM_ROLLOFF_FACTOR, 92 | wxTextCtrl* textField_flRoomRolloffFactor; 93 | 94 | //properties of zone to creates 95 | 96 | std::string name; 97 | double xPosition; 98 | double yPosition; 99 | double zPosition; 100 | double width; 101 | double height; 102 | 103 | ReverbStandardProperties properties; 104 | 105 | void initPrivateVariables(); 106 | 107 | bool okClicked; 108 | 109 | void SoundProducerTrackSelectedInListBox(wxCommandEvent& event ); 110 | 111 | 112 | 113 | }; 114 | 115 | 116 | 117 | #endif 118 | -------------------------------------------------------------------------------- /include/soundproducer-registry.h: -------------------------------------------------------------------------------- 1 | #ifndef SOUND_PRODUCER_REGISTRY 2 | #define SOUND_PRODUCER_REGISTRY 3 | 4 | #include "soundproducer.h" 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | //class to contain map of sound producer pointers and their keys 13 | 14 | class SoundProducerRegistry 15 | { 16 | public: 17 | 18 | void SetReferenceToSoundProducerVector(std::vector > *sound_producer_vector); 19 | 20 | SoundProducer* GetPointerToSoundProducerWithThisName(std::string thisName); 21 | 22 | //Add or remove sound producer from registry 23 | void AddRecentSoundProducerMadeToRegistry(); 24 | void RemoveSoundProducerFromRegistry(SoundProducer* thisSoundProducer); 25 | 26 | //function to return list of sound producers to edit 27 | wxArrayString& GetSoundProducersToEditList(); 28 | 29 | //function to remove a name from the list of sound producers to edit 30 | //use if a name is already being edited by a track 31 | void RemoveThisNameFromEditingList(std::string thisName); 32 | 33 | //function to add a name from the list of sound producers to edit 34 | //use if a name was removed for editing because it was being edited and then it stopped being edited 35 | void AddThisNameToEditingList(std::string thisName); 36 | 37 | //function to add all names of soundproducers in map to editor list 38 | //use with RemoveThisNameFromEditingList to get back a soundproducer to editing list after it is not edited in soundproducer track 39 | void AddAllSoundProducersToEditingList(); 40 | 41 | //function to add reference to combo box to combo_box_ptr_vec 42 | void AddReferenceToComboBox(wxComboBox* thisComboBox); 43 | 44 | //function to remove a combo box pointer from container, use when soundproducer track is removed 45 | void RemoveLastComboBoxReference(); 46 | 47 | //function to update all comboboxes list, used for updating list after removal of a selection that is being edited by a soundproducer track 48 | void UpdateAllComboBoxesList(); 49 | 50 | //function to remove a string name from all combo boxes except for one 51 | void RemoveThisNameFromAllComboBoxesExceptThisOne(std::string thisName, wxComboBox* thisCombobox); 52 | 53 | //function to clear all names from registry 54 | void ClearAllSoundproducerNames(); 55 | 56 | //function to clear all 57 | void ClearAll(); 58 | 59 | private: 60 | 61 | //list of names for combo box 62 | wxArrayString soundproducers_to_edit_wxstring; 63 | 64 | //pointer to vector of sound producers to edit 65 | std::vector > *sound_producer_vector_ref; 66 | 67 | //vector of pointers to combo boxes 68 | //used to update all combo boxes 69 | std::vector combo_box_ptr_vec; 70 | 71 | //dictionary to keep track of which wxstring associated with index 72 | //std::unordered_map >::iterator> map_soundproducer; 73 | std::unordered_map map_soundproducer; 74 | }; 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /include/effect-zone.h: -------------------------------------------------------------------------------- 1 | #ifndef EFFECT_ZONE_H 2 | #define EFFECT_ZONE_H 3 | 4 | 5 | #include "AL/al.h" //header for OpenAL Soft 6 | #include "AL/alc.h" //header for OpenAL Soft 7 | #include "AL/alext.h" //header for OpenAL Soft 8 | #include "AL/efx.h" 9 | #include "AL/efx-presets.h" 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include //for object to render on screen 18 | #include //for matrix transform that moves object rendered 19 | #include //for object rendered to be moved on screen by matrix transform 20 | 21 | struct ZoneColor 22 | { 23 | float r; //red 24 | float g; //green 25 | float b; //blue 26 | float alpha; //transparency 27 | }; 28 | 29 | class EffectZone 30 | { 31 | 32 | public: 33 | EffectZone(); 34 | ~EffectZone(); 35 | 36 | //name of zone 37 | 38 | void SetNameString(std::string& thisName); 39 | std::string GetNameString(); 40 | 41 | 42 | //Position 43 | 44 | void SetPositionX(double& x); //set x position of sound producer 45 | double GetPositionX(); //get x position of sound producer 46 | void SetPositionY(double& y); //set y position of sound producer 47 | double GetPositionY(); //get y position of sound producer 48 | void SetPositionZ(double& z); //set z position of sound producer 49 | double GetPositionZ(); //get z position of sound producer 50 | 51 | 52 | //functions to initialize effect zone 53 | 54 | void InitEffectZone(std::string& thisName, 55 | double& x, double& y, double& z, double& width); 56 | 57 | void InitEffectZoneWithGraphicalObject(std::string& thisName, 58 | double& x, double& y, double& z, double& width, 59 | ZoneColor& color); 60 | 61 | 62 | //3d Object properties 63 | osg::ShapeDrawable* getRenderObject(); 64 | 65 | osg::Geode* getGeodeNode(); 66 | 67 | osg::PositionAttitudeTransform* getTransformNode(); 68 | 69 | void ChangeWidth(double width); 70 | double GetWidth(); 71 | 72 | void SetColor(ZoneColor color); 73 | 74 | //OpenAL Soft effects properties 75 | 76 | void SetEffectsSlotPointer(ALuint* slot_ptr); 77 | 78 | virtual ALuint* GetEffectPointer(); 79 | virtual ALuint* GetEffectsSlotPointer(); 80 | 81 | virtual ALuint GetEffect(); 82 | virtual ALuint GetEffectsSlot(); 83 | 84 | virtual void FreeEffects(); 85 | 86 | 87 | private: 88 | 89 | ALuint* m_slot_ptr; 90 | 91 | //Name of echo Zone 92 | std::string name; 93 | 94 | //position of echo zone 95 | std::vector position_vector; 96 | enum POSITION_INDEX { X=0,Y=1,Z=2 }; 97 | 98 | double m_width; 99 | 100 | //ShapeDrawable object to render 101 | osg::ref_ptr m_renderObject; 102 | 103 | osg::ref_ptr m_box; 104 | 105 | //holds geometry information for rendering, moved by transform of matrix 106 | osg::ref_ptr m_geode; 107 | 108 | //moves the geode 109 | osg::ref_ptr m_paTransform; 110 | 111 | ZoneColor m_color; 112 | }; 113 | 114 | #endif 115 | -------------------------------------------------------------------------------- /docs/overview-of-systems.md: -------------------------------------------------------------------------------- 1 | # Overview of Systems in Binaural Audio Editor 2 | 3 | These are the main three systems that binaural audio editor interfaces with. 4 | - Main Graphical User Interface, GUI 5 | - OpenAL Soft Audio Engine 6 | - Timeline Track Editor 7 | 8 | ## Main Graphical User Interface, GUI 9 | This is what puts together everything seen in binaural audio editor. 10 | 11 | 12 | ### Files to look at: 13 | - `osgViewerWX.h` 14 | - `osgViewerWX.cpp` 15 | - `SoundProducerTrackManager.h` 16 | - `SoundProducerTrackManager.cpp` 17 | - Files with Dialog in the filename in include and src folder. 18 | 19 | #### In`osgViewerWX.cpp` and `osgViewerWX.h` 20 | 21 | **OsgCanvas** is a class to show the OpenSceneGraph window and 3D objects. 22 | 23 | **GraphicsWindowWX** is a class that contains OsgCanvas and contains the rendering output in a window. 24 | 25 | **MainFrame** is the window that contains the menu bar above and its items, contains the timeline editor, and opens dialogs/windows when a menu item is clicked on. 26 | 27 | Since it is the main part that user interacts with, MainFrame also contains important classes such as TimelineFrame, reference to OpenALSoftAudioEngine, reference to Listener, SoundProducerTrackManager, vector of SoundProducerTrack, ListenerTrack. 28 | 29 | **wxOsgApp** is the main of the wxWidgets appplication, much like the main of a basic C++ program. It contains MainFrame and initializes it. 30 | 31 | #### In`SoundProducerTrackManager.cpp` and `SoundProducerTrackManager.h` 32 | 33 | **SoundProducerTrackManager** is a class that handles multiple sound producer tracks, buffers the audio, and plays the audio of sound producer tracks in sync. 34 | 35 | ## OpenALSoftAudioEngine 36 | This is a class to abstract 3D audio operations involving OpenAL Soft. 37 | 38 | It is mostly just used to initialize the OpenAL system and query and test HRTF support. 39 | 40 | ### Files to look at 41 | - `openalsoftaudioengine.h` 42 | - `openalsoftaudioengine.cpp` 43 | 44 | ## Timeline Track Editor 45 | This is a very big important module that is used by binaural audio editor. 46 | 47 | It is imported from Timeline Track Editor github https://github.com/adct-the-experimenter/timeline-track-editor. 48 | 49 | This module is contained in its own folder in src/timeline-track-editor. 50 | 51 | The timeline track editor module contains many important classes such as Track, DoubleTrack, StereoAudioTrack, and TimelineFrame. This is the module to edit to improve the tracks and timeline and see how audio gets buffered. 52 | 53 | **Without the Timeline Track Editor module, there would not be a listener track, soundproducer track, or even a timeline for playing audio!** 54 | 55 | The reasons this is developed into its own separate project: 56 | - It is very big. 57 | - It is functional apart from binaural audio editor. 58 | - It is much easier and cleaner to edit it as its own project rather than inside binaural audio editor. 59 | 60 | ### Files to look at 61 | - `src/timeline-track-editor/include/timeline-frame.h` 62 | - `src/timeline-track-editor/src/timeline-frame.cpp` 63 | - `src/timeline-track-editor/include/openalsoft-player.h` 64 | - `src/timeline-track-editor/src/openalsoft-player.cpp` 65 | - `src/timeline-track-editor/include/double-track.h` 66 | - `src/timeline-track-editor/src/double-track.cpp` 67 | - `src/timeline-track-editor/include/stereo-audio-track.h` 68 | - `src/timeline-track-editor/src/stereo-audio-track.cpp` 69 | -------------------------------------------------------------------------------- /include/CreateEAXReverbZoneDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef CREATE_EAX_REVERB_ZONE_H 2 | #define CREATE_EAX_REVERB_ZONE_H 3 | 4 | #include 5 | 6 | #include //for wxFloatingPointValidator 7 | #include //for wxTextCtrl 8 | 9 | #include "effects-manager.h" 10 | 11 | 12 | 13 | class CreateEAXReverbZoneDialog : public wxDialog 14 | { 15 | 16 | public: 17 | CreateEAXReverbZoneDialog(const wxString& title,EffectsManager* effects_manager); 18 | 19 | 20 | void OnOk(wxCommandEvent& event); 21 | 22 | void OnCancel(wxCommandEvent& event); 23 | 24 | void OnPreview(wxCommandEvent& event); 25 | 26 | void Exit(); 27 | 28 | 29 | //function to return position of new sound producer object 30 | void getNewPosition(double& x, double& y, double& z); 31 | 32 | std::string getNewName(); 33 | 34 | double& getNewWidth(); 35 | 36 | ReverbEAXProperties& getNewProperties(); 37 | 38 | enum 39 | { 40 | ID_OK = wxID_HIGHEST + 1, 41 | ID_PREVIEW, 42 | ID_APPLY, 43 | ID_CANCEL, 44 | ID_RENAME, 45 | ID_LISTBOX 46 | }; 47 | 48 | bool OkClicked(); 49 | 50 | private: 51 | EffectsManager* m_effects_manager_ptr; 52 | 53 | wxButton* okButton; 54 | wxButton* cancelButton; 55 | wxButton* previewButton; 56 | 57 | 58 | wxTextCtrl* textFieldName; 59 | 60 | wxTextCtrl* textFieldX; 61 | wxTextCtrl* textFieldY; 62 | wxTextCtrl* textFieldZ; 63 | wxTextCtrl* textFieldWidth; 64 | 65 | wxListBox* listboxSoundProducers; 66 | int spt_selection_index; 67 | 68 | void SoundProducerTrackSelectedInListBox(wxCommandEvent& event ); 69 | 70 | //AL_REVERB_DENSITY, 71 | wxTextCtrl* textField_flDensity; 72 | //AL_REVERB_DIFFUSION, 73 | wxTextCtrl* textField_flDiffusion; 74 | //AL_REVERB_GAIN, 75 | wxTextCtrl* textField_flGain; 76 | //AL_REVERB_GAINHF, 77 | wxTextCtrl* textField_flGainHF; 78 | //AL_EAXREVERB_GAINLF, 79 | wxTextCtrl* textField_flGainLF; 80 | //AL_REVERB_DECAY_TIME, 81 | wxTextCtrl* textField_flDecayTime; 82 | //AL_REVERB_DECAY_HFRATIO, 83 | wxTextCtrl* textField_flDecayHFRatio; 84 | //AL_EAXREVERB_DECAY_LFRATIO, 85 | wxTextCtrl* textField_flDecayLFRatio; 86 | //AL_REVERB_REFLECTIONS_GAIN, 87 | wxTextCtrl* textField_flReflectionsGain; 88 | //AL_REVERB_REFLECTIONS_DELAY, 89 | wxTextCtrl* textField_flReflectionsDelay; 90 | //AL_REVERB_LATE_REVERB_GAIN, 91 | wxTextCtrl* textField_flLateReverbGain; 92 | //AL_REVERB_LATE_REVERB_DELAY, 93 | wxTextCtrl* textField_flLateReverbDelay; 94 | //AL_EAXREVERB_ECHO_TIME, 95 | wxTextCtrl* textField_flEchoTime; 96 | //AL_EAXREVERB_ECHO_DEPTH, 97 | wxTextCtrl* textField_flEchoDepth; 98 | //AL_EAXREVERB_MODULATION_TIME, 99 | wxTextCtrl* textField_flModulationTime; 100 | //AL_EAXREVERB_MODULATION_DEPTH, 101 | wxTextCtrl* textField_flModulationDepth; 102 | //AL_EAXREVERB_HFREFERENCE, 103 | wxTextCtrl* textField_flHFReference; 104 | //AL_EAXREVERB_LFREFERENCE, 105 | wxTextCtrl* textField_flLFReference; 106 | //AL_REVERB_AIR_ABSORPTION_GAINHF, 107 | wxTextCtrl* textField_flAirAbsorptionGainHF; 108 | //AL_REVERB_ROOM_ROLLOFF_FACTOR, 109 | wxTextCtrl* textField_flRoomRolloffFactor; 110 | 111 | std::string name; 112 | double xPosition; 113 | double yPosition; 114 | double zPosition; 115 | double width; 116 | 117 | ReverbEAXProperties properties; 118 | 119 | void initPrivateVariables(); 120 | 121 | bool okClicked; 122 | 123 | }; 124 | 125 | 126 | 127 | #endif 128 | -------------------------------------------------------------------------------- /include/EditMultipleEAXReverbZonesDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef EDIT_MULTIPLE_EAX_REVERB_ZONES_DIALOG_H 2 | #define EDIT_MULTIPLE_EAX_REVERB_ZONES_DIALOG_H 3 | 4 | #include 5 | #include 6 | 7 | #include //for wxFloatingPointValidator 8 | #include //for wxTextCtrl 9 | #include //for list box 10 | 11 | #include "effects-manager.h" 12 | 13 | class EditMultipleEAXReverbZonesDialog : public wxDialog 14 | { 15 | 16 | public: 17 | EditMultipleEAXReverbZonesDialog(const wxString& title,EffectsManager* effects_manager); 18 | 19 | 20 | void OnOk(wxCommandEvent& event ); 21 | 22 | void OnCancel(wxCommandEvent& event); 23 | 24 | void OnApply(wxCommandEvent& event); 25 | 26 | void OnPreview(wxCommandEvent& event); 27 | 28 | void Exit(); 29 | 30 | 31 | private: 32 | 33 | EffectsManager* effects_manager_ptr; //pointer to vector of sound producers to edit 34 | 35 | //ReverbStandardProperties tempStandardRevProp; 36 | ReverbEAXProperties tempEAXRevProp; 37 | 38 | std::string name; 39 | double xPosition; 40 | double yPosition; 41 | double zPosition; 42 | double width; 43 | 44 | wxButton* okButton; 45 | wxButton* cancelButton; 46 | wxButton* applyButton; 47 | wxButton* previewButton; 48 | 49 | int m_selection_index; 50 | 51 | wxListBox* listboxReverbZones; 52 | 53 | void initPrivateVariables(); 54 | 55 | void ChangeReverbZoneAttributes(); 56 | 57 | void ReverbZoneSelectedInListBox(wxCommandEvent& event ); 58 | 59 | wxListBox* listboxSoundProducers; 60 | int spt_selection_index; 61 | 62 | void SoundProducerTrackSelectedInListBox(wxCommandEvent& event ); 63 | 64 | //text fields 65 | wxTextCtrl* textFieldName; 66 | 67 | wxTextCtrl* textFieldX; 68 | wxTextCtrl* textFieldY; 69 | wxTextCtrl* textFieldZ; 70 | wxTextCtrl* textFieldWidth; 71 | 72 | 73 | 74 | //AL_REVERB_DENSITY, 75 | wxTextCtrl* textField_flDensity; 76 | //AL_REVERB_DIFFUSION, 77 | wxTextCtrl* textField_flDiffusion; 78 | //AL_REVERB_GAIN, 79 | wxTextCtrl* textField_flGain; 80 | //AL_REVERB_GAINHF, 81 | wxTextCtrl* textField_flGainHF; 82 | //AL_EAXREVERB_GAINLF, 83 | wxTextCtrl* textField_flGainLF; 84 | //AL_REVERB_DECAY_TIME, 85 | wxTextCtrl* textField_flDecayTime; 86 | //AL_REVERB_DECAY_HFRATIO, 87 | wxTextCtrl* textField_flDecayHFRatio; 88 | //AL_EAXREVERB_DECAY_LFRATIO, 89 | wxTextCtrl* textField_flDecayLFRatio; 90 | //AL_REVERB_REFLECTIONS_GAIN, 91 | wxTextCtrl* textField_flReflectionsGain; 92 | //AL_REVERB_REFLECTIONS_DELAY, 93 | wxTextCtrl* textField_flReflectionsDelay; 94 | //AL_REVERB_LATE_REVERB_GAIN, 95 | wxTextCtrl* textField_flLateReverbGain; 96 | //AL_REVERB_LATE_REVERB_DELAY, 97 | wxTextCtrl* textField_flLateReverbDelay; 98 | //AL_EAXREVERB_ECHO_TIME, 99 | wxTextCtrl* textField_flEchoTime; 100 | //AL_EAXREVERB_ECHO_DEPTH, 101 | wxTextCtrl* textField_flEchoDepth; 102 | //AL_EAXREVERB_MODULATION_TIME, 103 | wxTextCtrl* textField_flModulationTime; 104 | //AL_EAXREVERB_MODULATION_DEPTH, 105 | wxTextCtrl* textField_flModulationDepth; 106 | //AL_EAXREVERB_HFREFERENCE, 107 | wxTextCtrl* textField_flHFReference; 108 | //AL_EAXREVERB_LFREFERENCE, 109 | wxTextCtrl* textField_flLFReference; 110 | //AL_REVERB_AIR_ABSORPTION_GAINHF, 111 | wxTextCtrl* textField_flAirAbsorptionGainHF; 112 | //AL_REVERB_ROOM_ROLLOFF_FACTOR, 113 | wxTextCtrl* textField_flRoomRolloffFactor; 114 | 115 | }; 116 | 117 | #endif 118 | -------------------------------------------------------------------------------- /include/effects-manager.h: -------------------------------------------------------------------------------- 1 | #ifndef EFFECTS_MANAGER_H 2 | #define EFFECTS_MANAGER_H 3 | 4 | 5 | #include "soundproducer-track-manager.h" 6 | #include "reverb-zone.h" 7 | #include "echo-zone.h" 8 | 9 | #include "listener.h" 10 | 11 | //class to manipulate x,y z position of sound producer 12 | class EffectsManager 13 | { 14 | public: 15 | EffectsManager(SoundProducerTrackManager* track_manager, Listener* listener); 16 | ~EffectsManager(); 17 | 18 | //function to create reverb zone that uses standard effects 19 | void CreateStandardReverbZone(std::string& name, double& x, double& y, double& z, double& width, ReverbStandardProperties& properties); 20 | 21 | //function to create reverb zone that uses EAX effectss 22 | void CreateEAXReverbZone(std::string& name, double& x, double& y, double& z, double& width, ReverbEAXProperties& properties); 23 | 24 | //function to create echo zone 25 | void CreateEchoZone(std::string& name, double& x, double& y, double& z, double& width, EchoZoneProperties& properties); 26 | 27 | //function to return a pointer to reverb zone vector 28 | std::vector *GetReferenceToEffectZoneVector(); 29 | 30 | //function to return a pointer to reverb zone from index in vector 31 | EffectZone* GetPointerToEffectZone(size_t& index); 32 | ReverbZone* GetPointerToStandardReverbZone(size_t& index); 33 | ReverbZone* GetPointerToEAXReverbZone(size_t& index); 34 | EchoZone* GetPointerToEchoZone(size_t& index); 35 | 36 | //function to run to apply reverb zone effect if listener is in reverb zone 37 | void RunListenerInEffectZoneOperation(); 38 | 39 | //function to free reverb zone effects 40 | void FreeEffects(); 41 | 42 | 43 | friend class CheckListenerReverbZoneThread; 44 | 45 | friend class CreateEAXReverbZoneDialog; 46 | friend class CreateStandardReverbZoneDialog; 47 | friend class CreateEchoZoneDialog; 48 | 49 | friend class EditMultipleStandardReverbZonesDialog; 50 | friend class EditMultipleEAXReverbZonesDialog; 51 | friend class EditMultipleEchoZonesDialog; 52 | 53 | friend class SaveSystem; 54 | friend class LoadSystem; 55 | 56 | private: 57 | 58 | //pointer to manager that contains all soundproducer tracks used 59 | SoundProducerTrackManager* m_track_manager_ptr; 60 | 61 | //pointer to listener 62 | Listener* m_listener_ptr; 63 | 64 | //vector to contain many reverb zone objects 65 | std::vector effect_zones_vector; 66 | 67 | std::vector standard_reverb_zones_vector; 68 | std::vector eax_reverb_zones_vector; 69 | 70 | std::vector echo_zones_vector; 71 | 72 | //function to perform the entire reverb thread operation of checking and setting reverb 73 | void PerformReverbThreadOperation(); 74 | 75 | //function to return bool of if a listener is in a reverb zone 76 | bool IsListenerInThisEffectZone(EffectZone* thisZone); 77 | 78 | //function to return bool of if a sound producer is in a reverb zone 79 | bool IsThisSoundProducerInsideEffectZone(SoundProducer* thisSoundProducer,EffectZone* thisZone); 80 | 81 | //function to apply reverb effect of a zone to sound producer track 82 | void ApplyThisEffectZoneEffectToThisTrack(SoundProducerTrack* thisSoundProducerTrack, EffectZone* thisZone); 83 | 84 | //function to remove effect applied to the sound producer track 85 | void RemoveEffectFromThisTrack(SoundProducerTrack* thisSoundProducerTrack); 86 | 87 | std::vector *GetReferenceToSoundProducerTracksVector(); 88 | }; 89 | 90 | 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /include/soundproducer.h: -------------------------------------------------------------------------------- 1 | #ifndef SOUNDPRODUCER_H 2 | #define SOUNDPRODUCER_H 3 | 4 | #include "AL/al.h" //header for OpenAL Soft 5 | #include "AL/alc.h" //header for OpenAL Soft 6 | #include "AL/alext.h" //header for OpenAL Soft 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include //for object to render on screen 15 | #include //for matrix transform that moves object rendered 16 | #include //for object rendered to be moved on screen by matrix transform 17 | 18 | //This is a class that holds positional info on object 19 | //as well as source and buffer components for use with sound producer track 20 | 21 | struct SoundProducerSaveData 22 | { 23 | //name 24 | std::string name; 25 | 26 | //position 27 | double x; 28 | double y; 29 | double z; 30 | 31 | //filepath 32 | std::string file_path; 33 | }; 34 | 35 | 36 | class SoundProducer 37 | { 38 | public: 39 | SoundProducer(); 40 | ~SoundProducer(); 41 | 42 | void SetNameString(std::string& thisName); 43 | std::string GetNameString(); 44 | 45 | void SetPositionX(double& x); //set x position of sound producer 46 | double GetPositionX(); //get x position of sound producer 47 | void SetPositionY(double& y); //set y position of sound producer 48 | double GetPositionY(); //get y position of sound producer 49 | void SetPositionZ(double& z); //set z position of sound producer 50 | double GetPositionZ(); //get z position of sound producer 51 | 52 | void InitSoundProducer(std::string& thisName, std::string& filepath, ALuint& buffer, 53 | double& x, double& y, double& z); 54 | 55 | void setFilepathToSound(std::string& filepath); 56 | std::string& getFilepathToSound(); 57 | 58 | void setBuffer(ALuint& thisSource); 59 | ALuint* getBuffer(); 60 | 61 | //function to use openal soft audio engine to create source from buffer 62 | void CreateSource(); 63 | 64 | void setSource(ALuint& thisSource); 65 | ALuint* getSource(); 66 | 67 | void SetReferenceToTrackSource(ALuint* thisSource); 68 | 69 | osg::ShapeDrawable* getRenderObject(); 70 | 71 | osg::Geode* getGeodeNode(); 72 | 73 | osg::PositionAttitudeTransform* getTransformNode(); 74 | 75 | SoundProducerSaveData GetSoundProducerSaveData(); 76 | void LoadSoundProducerSaveData(SoundProducerSaveData& data); 77 | 78 | void SetFreeRoamBool(bool state); 79 | bool GetFreeRoamBool(); 80 | 81 | private: 82 | //Name of Sound Producer 83 | std::string name; 84 | 85 | //position of Sound Producer 86 | std::vector producer_position_vector; 87 | enum POSITION_INDEX { X=0,Y=1,Z=2 }; 88 | 89 | //file path to sound made 90 | std::string m_filepath; 91 | 92 | //buffer to play 93 | ALuint m_buffer; 94 | 95 | //source to play buffer 96 | ALuint m_source; 97 | 98 | ALuint* track_source_ptr; 99 | 100 | void moveSource(); //function to move source to producer position vector coordinates 101 | 102 | //ShapeDrawable object to render 103 | osg::ref_ptr m_renderObject; 104 | 105 | osg::ref_ptr m_box; 106 | 107 | //holds geometry information for rendering, moved by transform of matrix 108 | osg::ref_ptr m_geode; 109 | 110 | //moves the geode 111 | osg::ref_ptr m_paTransform; 112 | 113 | 114 | //save data 115 | SoundProducerSaveData m_saveData; 116 | 117 | //option for allowing sound producer to be moved by keys 118 | bool freeRoam; 119 | 120 | }; 121 | 122 | #endif 123 | -------------------------------------------------------------------------------- /include/listener-track.h: -------------------------------------------------------------------------------- 1 | #ifndef LISTENER_TRACK_H 2 | #define LISTENER_TRACK_H 3 | 4 | #include "listener-external.h" 5 | 6 | #include "double-track.h" 7 | 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include //for using quaternion to change orientation 14 | #include //for splitting string 15 | 16 | struct ListenerTrackSaveData 17 | { 18 | 19 | //double track save data 20 | 21 | //position 22 | DDMap* time_value_map_posx_ptr; 23 | DDMap* time_value_map_posy_ptr; 24 | DDMap* time_value_map_posz_ptr; 25 | 26 | //orientation 27 | DDMap* time_value_map_orientw_ptr; 28 | DDMap* time_value_map_orientx_ptr; 29 | DDMap* time_value_map_orienty_ptr; 30 | DDMap* time_value_map_orientz_ptr; 31 | 32 | }; 33 | 34 | //class to manipulate x,y z position of sound producer 35 | class ListenerTrack : public Track 36 | { 37 | public: 38 | ListenerTrack(const wxString& title); 39 | 40 | 41 | DoubleTrack* GetReferenceToXTrack(); 42 | DoubleTrack* GetReferenceToYTrack(); 43 | DoubleTrack* GetReferenceToZTrack(); 44 | 45 | DoubleTrack* GetReferenceToQuatWTrack(); 46 | DoubleTrack* GetReferenceToQuatXTrack(); 47 | DoubleTrack* GetReferenceToQuatYTrack(); 48 | DoubleTrack* GetReferenceToQuatZTrack(); 49 | 50 | //Listener Editing 51 | void SetReferenceToListenerToManipulate(Listener* thisListener); 52 | void SetReferenceToExternalListener(ListenerExternal* thisListenerExt); 53 | 54 | //Double Track related functions 55 | void SetupAxisForPositionVariable(double& start, double& end, double& resolution, int& numTick); 56 | void SetupAxisForOrientationVariable(double& start, double& end, double& resolution, int& numTick); 57 | 58 | void OnLeftMouseClick(wxMouseEvent& event); 59 | void OnRightMouseClick(wxCommandEvent& event); 60 | 61 | //Functions inherited from Track 62 | virtual void InitTrack(wxWindow* parent, std::vector *timeTickVector); 63 | 64 | virtual void OnPaint(wxPaintEvent& event); 65 | virtual void OnScroll(wxScrollEvent& event); 66 | virtual void OnSize(wxSizeEvent& event); 67 | 68 | void SetReferenceToCurrentTimeVariable(double* thisTimeVariable); 69 | void SetReferenceToTimeTickVector(std::vector *thisVector); 70 | 71 | std::vector *GetReferenceToTimeTickVector(); 72 | 73 | double GetCurrentTime(); 74 | 75 | //function to call in timer loop, variable to manipulate gets changed here 76 | virtual void FunctionToCallInPlayState(); 77 | virtual void FunctionToCallInPauseState(); 78 | virtual void FunctionToCallInRewindState(); 79 | virtual void FunctionToCallInFastForwardState(); 80 | virtual void FunctionToCallInNullState(); 81 | 82 | //save data 83 | ListenerTrackSaveData GetListenerTrackSaveData(); 84 | void LoadListenerTrackSaveData(ListenerTrackSaveData& data); 85 | 86 | private: 87 | Listener* listenerToManipulatePtr; 88 | ListenerExternal* listenerExternalPtr; 89 | 90 | DoubleTrack* xTrack; 91 | DoubleTrack* yTrack; 92 | DoubleTrack* zTrack; 93 | 94 | DoubleTrack* wQuatTrack; 95 | DoubleTrack* xQuatTrack; 96 | DoubleTrack* yQuatTrack; 97 | DoubleTrack* zQuatTrack; 98 | 99 | 100 | //variables to hold temporary values for listener position and orientation 101 | double tempX,tempY,tempZ,tempQuatX,tempQuatY,tempQuatZ,tempQuatW; 102 | 103 | //quaternions for intial forward vector and up vector directions 104 | boost::math::quaternion forward_vector_quaternion; 105 | boost::math::quaternion up_vector_quaternion; 106 | 107 | //listener track save data 108 | ListenerTrackSaveData m_saveData; 109 | }; 110 | 111 | #endif 112 | -------------------------------------------------------------------------------- /src/timeline-track-editor/include/openalsoft-player.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENALSOFT_PLAYER 2 | #define OPENALSOFT_PLAYER 3 | 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "time.h" 13 | 14 | #include "sndfile.h" 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include "AL/al.h" //header for OpenAL Soft 23 | #include "AL/alc.h" //header for OpenAL Soft 24 | #include "AL/alext.h" //header for OpenAL Soft 25 | 26 | #define NUM_BUFFERS 4 27 | #define BUFFER_TIME_MS 200 // 200 milliseconds 28 | #define MAX_CHANNELS 2 29 | 30 | class OpenALSoftPlayer 31 | { 32 | public: 33 | OpenALSoftPlayer(); 34 | ~OpenALSoftPlayer(); 35 | 36 | //Initialize OpenAL Soft system 37 | bool InitOpenALSoft(ALCdevice* thisAudioDevice, ALCcontext* thisAudioContext); 38 | 39 | //function to initialize buffers to play for streaming 40 | void InitBuffersForStreaming(); 41 | 42 | //function to initialize external source 43 | void InitSource(ALuint* source); 44 | 45 | //functions to set reference to audio device and audio context to use for player 46 | void SetReferenceToAudioDevice(ALCdevice* thisAudioDevice); 47 | void SetReferenceToAudioContext(ALCcontext* thisAudioContext); 48 | 49 | //functions to manipulate source 50 | void PlaySource(ALuint* thisSource); 51 | void PlayMultipleSources(std::vector *sources_vec); 52 | 53 | void PauseSource(ALuint* thisSource); 54 | void PauseMultipleSources(std::vector *sources_vec); 55 | 56 | void RewindSource(ALuint* thisSource); 57 | void RewindMultipleSources(std::vector *sources_vec); 58 | 59 | void StopSource(ALuint* thisSource); 60 | void StopMultipleSources(std::vector *sources_vec); 61 | 62 | //clear queue playing 63 | void ClearQueue(ALuint* thisSource); 64 | 65 | //function to stream source 66 | void StreamSource(ALuint* thisSource); 67 | 68 | //function to open file for streaming audio 69 | int OpenPlayerFile(const char *filename); 70 | 71 | //function to close current file loaded for streaming audio 72 | void ClosePlayerFile(); 73 | 74 | int StartPlayerBuffering(ALuint* source,double& current_time); 75 | 76 | int StartPlayingBuffer(ALuint* source); 77 | 78 | int UpdatePlayerBuffer(ALuint* source,double& current_time); 79 | 80 | int PlayUpdatedPlayerBuffer(ALuint* source); 81 | 82 | int PlayMultipleUpdatedPlayerBuffers(std::vector *sources_vec); 83 | 84 | void CloseOpenALSoft(ALCdevice* thisAudioDevice, ALCcontext* thisAudioContext); 85 | 86 | enum PlayerStatus 87 | { 88 | GOOD_PLAYING_STATUS=0, 89 | ERROR_CHECKING_SOURCE_STATE=1, 90 | FAILED_TO_READ_ANYMORE_AUDIO_FROM_FILE=2, 91 | ERROR_BUFFERING_DATA=3, 92 | ERROR_RESTARTING_PLAYBACK=4, 93 | PLAYBACK_FINISHED=5, 94 | ERROR_STARTING_PLAYBACK=6, 95 | GOOD_UPDATE_BUFFER_STATUS, 96 | GOOD_START_BUFFERING 97 | }; 98 | 99 | private: 100 | ALCdevice* audioDevicePtr; //pointer to audio device to be used 101 | ALCcontext* alContextPtr; //pointer to context of where audio is played 102 | 103 | ALuint buffers[NUM_BUFFERS]; 104 | //size of temporary buffers to read 105 | uint32_t buffer_size; 106 | 107 | /* The format of the output stream */ 108 | ALenum format; 109 | ALsizei sample_rate; 110 | 111 | //libsndfile file handle for input file 112 | SNDFILE *infile; 113 | 114 | //has info on file loaded 115 | SF_INFO sfinfo; 116 | 117 | int bit_size; 118 | 119 | size_t buffer_index; //keeps track of which buffer player is on 120 | }; 121 | 122 | #endif 123 | -------------------------------------------------------------------------------- /src/timeline-track-editor/include/mono-audio-track.h: -------------------------------------------------------------------------------- 1 | #ifndef MONOAUDIOTRACK_H 2 | #define MONOAUDIOTRACK_H 3 | 4 | #include "track.h" 5 | #include "audio-track.h" 6 | 7 | class MonoAudioTrack : public Track 8 | { 9 | public: 10 | MonoAudioTrack(const wxString& title); 11 | 12 | void SetReferenceToSourceToManipulate(ALuint* source); 13 | void SetReferenceToAudioPlayer(OpenALSoftPlayer* thisPlayer); 14 | 15 | void SetReferenceToBrowseButton(wxButton* thisButton); 16 | 17 | enum State 18 | { 19 | PLAYER_NULL = 0, 20 | PLAYER_STOPPED, 21 | PLAYER_PLAYING, 22 | PLAYER_PAUSED, 23 | PLAYER_REWINDING, 24 | PLAYER_FAST_FORWARDING 25 | }; 26 | 27 | void SetAudioTrackState(int thisState); 28 | int GetAudioTrackState(); 29 | 30 | AudioTrack* GetReferenceToChannelTrack(); 31 | 32 | enum Options 33 | { 34 | ONLY_BUFFER_AUDIO = 0, //for use with multiple stereo audio track in use and only need to buffer multiple sources, play sources all in sync with PlayMultipleUpdatedBuffers 35 | BUFFER_AND_PLAY_AUDIO //for use with only one stereo audio track and can play single buffer 36 | }; 37 | 38 | void SetTrackOption(int thisOption); 39 | int GetTrackOption(); 40 | 41 | //Audio Track related functions 42 | 43 | 44 | //Track related functions 45 | virtual void InitTrack(wxWindow* parent, std::vector *timeTickVector); 46 | 47 | //function to set bounds for variable to change as well as number of ticks to draw 48 | virtual void SetupAxisForVariable(double& start, double& end, double& resolution, int& numTick); 49 | 50 | 51 | virtual void OnPaint(wxPaintEvent& event); 52 | virtual void OnScroll(wxScrollEvent& event); 53 | virtual void OnSize(wxSizeEvent& event); 54 | void OnLeftMouseClick(wxMouseEvent& event); 55 | void OnRightMouseClick(wxCommandEvent& event); 56 | 57 | void SetReferenceToCurrentTimeVariable(double* thisTimeVariable); 58 | void SetReferenceToTimeTickVector(std::vector *thisVector); 59 | 60 | void SetReferenceToPlaybackControls(PlaybackControls* controls); 61 | PlaybackControls* GetReferenceToPlaybackControls(); 62 | 63 | void SetTitle(wxString thisTitle); 64 | wxString GetTitle(); 65 | 66 | std::vector *GetReferenceToTimeTickVector(); 67 | 68 | double GetCurrentTime(); 69 | 70 | //function to call in timer loop, variable to manipulate gets changed here 71 | virtual void FunctionToCallInPlayState(); 72 | virtual void FunctionToCallInPauseState(); 73 | virtual void FunctionToCallInRewindState(); 74 | virtual void FunctionToCallInFastForwardState(); 75 | virtual void FunctionToCallInNullState(); 76 | 77 | void SetFunctionToCallAfterVariableChange(std::function < void() > thisFunction); 78 | 79 | void render(wxDC& dc); 80 | void logic_left_click(); 81 | void logic_right_click(); 82 | 83 | private: 84 | 85 | AudioTrack* m_channel_track; 86 | 87 | //state of audio track 88 | int track_state; 89 | 90 | ALuint* sourceToManipulatePtr; 91 | OpenALSoftPlayer* audioPlayerPtr; 92 | 93 | //options for track 94 | int track_options; 95 | 96 | double verticalStart; //vertical axis start 97 | double verticalEnd; //vertical axis end 98 | double verticalResolution; 99 | int verticalNumTicks; //number of tick marks in vertical axis 100 | 101 | std::function < void() > func_after_var_change; 102 | 103 | wxButton* browseButton; 104 | void OnBrowse(wxCommandEvent& event); 105 | 106 | std::string inputSoundFilePath; 107 | std::string streamSoundFilePath; 108 | 109 | PlaybackControls* playbackControlsPtr; 110 | 111 | void al_nssleep(unsigned long nsec); 112 | 113 | }; 114 | 115 | #endif 116 | -------------------------------------------------------------------------------- /src/timeline-track-editor/src/timeline-frame.cpp: -------------------------------------------------------------------------------- 1 | #include "timeline-frame.h" 2 | 3 | TimelineFrame::TimelineFrame(wxWindow *parent) : wxFrame(parent, wxID_ANY, "Timeline Frame") 4 | { 5 | //make horizontal box to put names in 6 | wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL); 7 | 8 | timelineWindowPtr = new TimelineWindow(this); 9 | 10 | wxBoxSizer *hboxTimeline = new wxBoxSizer(wxHORIZONTAL); 11 | hboxTimeline->Add(timelineWindowPtr, 1, wxRIGHT | wxEXPAND, 0); 12 | 13 | //initialize playback controls 14 | controls = new PlaybackControls(this); 15 | controls->SetReferenceToTimelineWindow(timelineWindowPtr); 16 | 17 | //create Playback timer object to call playback controls RunPlaybackState() periodically 18 | timer = new PlaybackTimer(controls); 19 | 20 | wxBoxSizer *hboxPlayback = new wxBoxSizer(wxHORIZONTAL); 21 | hboxPlayback->Add(controls); 22 | 23 | vbox->Add(hboxPlayback); 24 | vbox->Add(hboxTimeline); 25 | 26 | // ensure that we have scrollbars initially 27 | SetClientSize(INITIAL_TIMELINE_WINDOW_WIDTH, INITIAL_TIMELINE_WINDOW_HEIGHT); 28 | 29 | //Not using SetSizer and Fit because that messes up the scrolling 30 | SetSizer(vbox); 31 | Center(); 32 | 33 | Show(); 34 | timer->start(); 35 | } 36 | 37 | TimelineFrame::~TimelineFrame() 38 | { 39 | if(controls != nullptr){delete controls;} 40 | if(timer != nullptr){delete timer;} 41 | if(timelineWindowPtr != nullptr){delete timelineWindowPtr;} 42 | } 43 | 44 | TimelineWindow* TimelineFrame::GetTimelineWindow(){return timelineWindowPtr;} 45 | 46 | void TimelineFrame::AddTrack(Track* thisTrack, int& space) 47 | { 48 | TimelineFrame::GetTimelineWindow()->AddTrack(thisTrack,space); 49 | } 50 | 51 | void TimelineFrame::AddTrackFunctionToCallInTimerLoopPlayState(Track* thisTrack) 52 | { 53 | std::function< void() > func = std::bind(&Track::FunctionToCallInPlayState, thisTrack); 54 | timer->AddFunctionToTimerLoopPlayState(func ); 55 | } 56 | 57 | void TimelineFrame::AddTrackFunctionToCallInTimerLoopPauseState(Track* thisTrack) 58 | { 59 | std::function< void() > func = std::bind(&Track::FunctionToCallInPauseState, thisTrack); 60 | timer->AddFunctionToTimerLoopPauseState(func ); 61 | } 62 | 63 | void TimelineFrame::AddTrackFunctionToCallInTimerLoopRewindState(Track* thisTrack) 64 | { 65 | std::function< void() > func = std::bind(&Track::FunctionToCallInRewindState, thisTrack); 66 | timer->AddFunctionToTimerLoopRewindState(func ); 67 | } 68 | 69 | void TimelineFrame::AddTrackFunctionToCallInTimerLoopFastForwardState(Track* thisTrack) 70 | { 71 | std::function< void() > func = std::bind(&Track::FunctionToCallInFastForwardState, thisTrack); 72 | timer->AddFunctionToTimerLoopFastForwardState(func ); 73 | } 74 | 75 | void TimelineFrame::AddTrackFunctionToCallInTimerLoopNullState(Track* thisTrack) 76 | { 77 | std::function< void() > func = std::bind(&Track::FunctionToCallInNullState, thisTrack); 78 | timer->AddFunctionToTimerLoopNullState(func ); 79 | } 80 | 81 | void TimelineFrame::AddSpacerBlock(int space) 82 | { 83 | TimelineFrame::GetTimelineWindow()->AddSpacerBlock(space); 84 | } 85 | 86 | void TimelineFrame::AddText(wxString thisText, wxPoint thisPoint) 87 | { 88 | TimelineFrame::GetTimelineWindow()->AddText(thisText,thisPoint); 89 | } 90 | 91 | void TimelineFrame::AddBoxSizer(wxSizer *sizer,int proportion,int flag,int border,wxObject *userData) 92 | { 93 | TimelineFrame::GetTimelineWindow()->AddBoxSizer(sizer,proportion,flag,border,userData); 94 | } 95 | 96 | void TimelineFrame::OnClose(wxCloseEvent& evt) 97 | { 98 | timer->Stop(); 99 | evt.Skip(); 100 | } 101 | 102 | PlaybackControls* TimelineFrame::GetPlaybackControlsReference(){return controls;} 103 | 104 | BEGIN_EVENT_TABLE(TimelineFrame, wxFrame) 105 | EVT_CLOSE(TimelineFrame::OnClose) 106 | END_EVENT_TABLE() 107 | -------------------------------------------------------------------------------- /src/Change-HRTF-Dialog.cpp: -------------------------------------------------------------------------------- 1 | #include "Change-HRTF-Dialog.h" 2 | 3 | ChangeHRTFDialog::ChangeHRTFDialog(const wxString & title,OpenAlSoftAudioEngine* audioEngine) 4 | : wxDialog(NULL, -1, title, wxDefaultPosition, wxSize(300, 250), wxRESIZE_BORDER) 5 | { 6 | selection_index = 0; 7 | 8 | ptrAudioEngine = audioEngine; 9 | 10 | ChangeHRTFDialog::initPrivateVariables(); 11 | 12 | wxStaticText* currentHRTFText = new wxStaticText(this, -1, wxT("Currently Selected HRTF :"), wxPoint(20, 40)); 13 | 14 | wxString thisString(ptrAudioEngine->GetCurrentHRTFSelected()); 15 | wxStaticText* currentHRTFTextHRTF = new wxStaticText(this, -1, thisString, wxPoint(40, 60)); 16 | 17 | wxBoxSizer *text_vbox = new wxBoxSizer(wxVERTICAL); 18 | text_vbox->Add(currentHRTFText, 1, wxTOP, 0); 19 | text_vbox->Add(currentHRTFTextHRTF, 1, wxTOP, 0); 20 | 21 | //list box to contain names of Sound Producers to edit, single selection by default 22 | listbox = new wxListBox(this, ID_LISTBOX,wxPoint(0, 0), wxSize(200, 200)); 23 | 24 | //add all HRTF names to listbox 25 | ptrAudioEngine->GetAvailableHRTFNames(&hrtf_names); 26 | 27 | if(hrtf_names.size() == 0) 28 | { 29 | wxMessageBox( wxT("No HRTF found! Check Test HRTF results. Check OpenAL Soft path for HRTF.") ); 30 | } 31 | else 32 | { 33 | for(size_t i = 0; i < hrtf_names.size(); i++) 34 | { 35 | wxString thisName(hrtf_names[i]); 36 | listbox->Append(thisName); 37 | } 38 | } 39 | 40 | //initialize Ok and Cancel buttons 41 | okButton = new wxButton(this, ChangeHRTFDialog::ID_OK, wxT("Ok"),wxDefaultPosition, wxSize(70, 30)); 42 | 43 | //make horizontal box to put ok and cancel buttons in 44 | wxBoxSizer *hboxBottom = new wxBoxSizer(wxHORIZONTAL); 45 | 46 | 47 | hboxBottom->Add(okButton, 0); 48 | 49 | //initialize change button 50 | changeButton = new wxButton(this, ChangeHRTFDialog::ID_CHANGE, wxT("Change"),wxDefaultPosition, wxSize(70, 30)); 51 | 52 | //Make vertical box to put everything in 53 | wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL); 54 | 55 | //add panel of text fields in vertical box 56 | vbox->Add(text_vbox, 0, wxBOTTOM, 1); 57 | vbox->Add(changeButton, 0, wxALL, 1); 58 | vbox->Add(listbox, 1, wxALL, 0); 59 | vbox->Add(hboxBottom, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, 10); 60 | 61 | SetSizerAndFit(vbox); 62 | 63 | //center and show elements in dialog 64 | Centre(); 65 | ShowModal(); 66 | 67 | //destroy when done showing 68 | Destroy(); 69 | } 70 | 71 | void ChangeHRTFDialog::initPrivateVariables() 72 | { 73 | listbox = nullptr; 74 | okButton = nullptr; 75 | } 76 | 77 | 78 | void ChangeHRTFDialog::OnOk(wxCommandEvent& event ) 79 | { 80 | ChangeHRTFDialog::Exit(); 81 | } 82 | 83 | void ChangeHRTFDialog::OnChange(wxCommandEvent& event) 84 | { 85 | if(ptrAudioEngine != nullptr) 86 | { 87 | if(selection_index != 0) 88 | { 89 | int index = selection_index - 1; //decrement to get original index 90 | std::string message; 91 | ptrAudioEngine->SelectThisHRTFByIndex(index,message); 92 | 93 | wxString thisString(message); 94 | wxMessageBox(thisString); 95 | } 96 | } 97 | } 98 | 99 | void ChangeHRTFDialog::Exit() 100 | { 101 | if(okButton != nullptr){ delete okButton;} 102 | if(listbox != nullptr){delete listbox;} 103 | if(changeButton != nullptr){delete changeButton;} 104 | Close( true ); //close window 105 | } 106 | 107 | void ChangeHRTFDialog::OnHRTFNameSelected(wxCommandEvent& event) 108 | { 109 | //increment by 1 so zero is left over for use as undefined 110 | selection_index = listbox->GetSelection() + 1; 111 | } 112 | 113 | //Event table for main frame specific events 114 | BEGIN_EVENT_TABLE(ChangeHRTFDialog, wxDialog) 115 | EVT_BUTTON (ID_OK, ChangeHRTFDialog::OnOk) 116 | EVT_BUTTON (ID_CHANGE, ChangeHRTFDialog::OnChange) 117 | EVT_LISTBOX (ID_LISTBOX, ChangeHRTFDialog::OnHRTFNameSelected) 118 | END_EVENT_TABLE() 119 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1.1) 2 | 3 | set (CMAKE_CXX_STANDARD 11) 4 | 5 | set(PROJECT_NAME binaural-audio-editor) 6 | project (${PROJECT_NAME} LANGUAGES C CXX) 7 | 8 | 9 | #-DCMAKE_BUILD_TYPE=Release 10 | set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -DDATADIR=${DATAPATH} -g -Wall -fPIE") 11 | set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -DDATADIR=${DATAPATH} -Wall -fPIE") 12 | 13 | #wxWidget specific stuff 14 | SET(wxWidgets_USE_LIBS) 15 | FIND_PACKAGE(wxWidgets COMPONENTS core base gl REQUIRED) 16 | if(wxWidgets_FOUND) 17 | include(${wxWidgets_USE_FILE}) 18 | endif() 19 | 20 | #OpenSceneGraph speicific stuff 21 | FIND_PACKAGE (OpenSceneGraph REQUIRED COMPONENTS osgUtil osgDB osgText osgGA osgFX osgSim osgViewer ) 22 | 23 | #for serial data stuff 24 | set(BOOST_LIBS date_time system) 25 | find_package(Boost COMPONENTS ${BOOST_LIBS} REQUIRED) 26 | find_package(Threads REQUIRED) 27 | 28 | 29 | #Pugi XML parsing 30 | find_path(pugixml_INCLUDE_DIRS pugixml.hpp) 31 | find_library(pugixml_LIBRARIES NAMES pugixml) 32 | 33 | #FreeBSD and linux specific include and libs 34 | #Note: for FreeBSD, use cmake .. -DwxWidgets_CONFIG_EXECUTABLE=/usr/local/bin/wxgtk3u-3.1-config 35 | 36 | #For the shared library: 37 | 38 | set ( PROJECT_LINK_LIBS ${wxWidgets_LIBRARIES} ${OPENSCENEGRAPH_LIBRARIES} openal sndfile ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${pugixml_LIBRARIES}) 39 | #where to find library files .so 40 | link_directories( /usr/lib /usr/local/lib ) 41 | 42 | if (WIN32) 43 | #add -lwsock32 to library dependencies for windows 44 | set (PROJECT_LINK_LIBS ${PROJECT_LINK_LIBS} -lwsock32) 45 | endif (WIN32) 46 | 47 | set ( PROJECT_INCLUDE_DIR ${wxWidgets_INCLUDE_DIRS} ${OPENSCENEGRAPH_INCLUDE_DIRS} ) 48 | 49 | #for where to find header files for source and library 50 | include_directories(/usr/include /usr/local/include ./include ./src/timeline-track-editor/include ${PROJECT_INCLUDE_DIR} ) 51 | 52 | set(SOURCES src/osgViewerWX.cpp 53 | src/SaveSystem.cpp src/LoadSystem.cpp src/XMLCreator.cpp src/XMLReader.cpp 54 | src/CreateStandardReverbZoneDialog.cpp src/EditMultipleStandardReverbZonesDialog.cpp 55 | src/CreateEAXReverbZoneDialog.cpp src/EditMultipleEAXReverbZonesDialog.cpp 56 | src/CreateEchoZoneDialog.cpp src/EditMultipleEchoZonesDialog.cpp 57 | src/echo-zone.cpp 58 | src/reverb-zone.cpp 59 | src/effect-zone.cpp 60 | src/effects-manager.cpp 61 | src/soundproducer-track-manager.cpp 62 | src/soundproducer-track.cpp 63 | src/listener-track.cpp 64 | src/soundproducer-registry.cpp 65 | src/CreateSoundProducerDialog.cpp src/EditMultipleSoundProducersDialog.cpp 66 | src/Change-HRTF-Dialog.cpp src/HRTF-Test-Dialog.cpp 67 | src/EditListenerDialog.cpp 68 | src/setup-serial-dialog.cpp 69 | src/listener-external.cpp 70 | src/openalsoftaudioengine.cpp src/soundproducer.cpp src/listener.cpp 71 | src/external-orientation-device-serial.cpp 72 | 73 | src/timeline-track-editor/src/timeline-frame.cpp 74 | src/timeline-track-editor/src/timeline-window.cpp 75 | src/timeline-track-editor/src/playback-controls.cpp 76 | src/timeline-track-editor/src/stereo-audio-track.cpp 77 | src/timeline-track-editor/src/mono-audio-track.cpp 78 | src/timeline-track-editor/src/audio-track.cpp 79 | src/timeline-track-editor/src/audio-graph.cpp 80 | src/timeline-track-editor/src/audio-stream-container.cpp 81 | src/timeline-track-editor/src/openalsoft-player.cpp 82 | src/timeline-track-editor/src/double-track.cpp 83 | src/timeline-track-editor/src/editor-graph.cpp 84 | src/timeline-track-editor/src/track.cpp 85 | ) 86 | 87 | #get_cmake_property(_variableNames VARIABLES) 88 | #list (SORT _variableNames) 89 | #foreach (_variableName ${_variableNames}) 90 | # message(STATUS "${_variableName}=${${_variableName}}") 91 | #endforeach() 92 | 93 | #make executable sphere from simple-sphere.cpp 94 | add_executable(${PROJECT_NAME} ${SOURCES}) 95 | #link libraries 96 | target_link_libraries(${PROJECT_NAME} ${PROJECT_LINK_LIBS}) 97 | 98 | #make install ops 99 | install(TARGETS binaural-audio-editor DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) 100 | 101 | -------------------------------------------------------------------------------- /src/timeline-track-editor/include/stereo-audio-track.h: -------------------------------------------------------------------------------- 1 | #ifndef STEREOAUDIOTRACK_H 2 | #define STEREOAUDIOTRACK_H 3 | 4 | #include "track.h" 5 | #include "audio-track.h" 6 | #include "playback-controls.h" 7 | 8 | class StereoAudioTrack : public Track 9 | { 10 | public: 11 | StereoAudioTrack(const wxString& title); 12 | 13 | void SetReferenceToSourceToManipulate(ALuint* source); 14 | void SetReferenceToAudioPlayer(OpenALSoftPlayer* thisPlayer); 15 | 16 | void SetReferenceToBrowseButton(wxButton* thisButton); 17 | 18 | enum State 19 | { 20 | PLAYER_NULL = 0, 21 | PLAYER_STOPPED, 22 | PLAYER_PLAYING, 23 | PLAYER_PAUSED, 24 | PLAYER_REWINDING, 25 | PLAYER_FAST_FORWARDING 26 | }; 27 | 28 | 29 | 30 | 31 | void SetAudioTrackState(int thisState); 32 | int GetAudioTrackState(); 33 | 34 | enum Options 35 | { 36 | ONLY_BUFFER_AUDIO = 0, //for use with multiple stereo audio track in use and only need to buffer multiple sources, play sources all in sync with PlayMultipleUpdatedBuffers 37 | BUFFER_AND_PLAY_AUDIO //for use with only one stereo audio track and can play single buffer 38 | }; 39 | 40 | void SetTrackOption(int thisOption); 41 | int GetTrackOption(); 42 | 43 | AudioTrack* GetReferenceToLeftChannelTrack(); 44 | AudioTrack* GetReferenceToRightChannelTrack(); 45 | 46 | void SetStreamAudioFilePath(std::string filepath); 47 | 48 | void BrowseForInputAudioFile(); 49 | 50 | void BufferAndPlayAudio(double& current_time); 51 | void StopAudio(); 52 | 53 | //Audio Track related functions 54 | 55 | 56 | //Track related functions 57 | virtual void InitTrack(wxWindow* parent, std::vector *timeTickVector); 58 | 59 | //function to set bounds for variable to change as well as number of ticks to draw 60 | virtual void SetupAxisForVariable(double& start, double& end, double& resolution, int& numTick); 61 | 62 | 63 | virtual void OnPaint(wxPaintEvent& event); 64 | virtual void OnScroll(wxScrollEvent& event); 65 | virtual void OnSize(wxSizeEvent& event); 66 | void OnLeftMouseClick(wxMouseEvent& event); 67 | void OnRightMouseClick(wxCommandEvent& event); 68 | 69 | void SetReferenceToCurrentTimeVariable(double* thisTimeVariable); 70 | void SetReferenceToTimeTickVector(std::vector *thisVector); 71 | 72 | void SetReferenceToPlaybackControls(PlaybackControls* controls); 73 | PlaybackControls* GetReferenceToPlaybackControls(); 74 | 75 | void SetTitle(wxString thisTitle); 76 | wxString GetTitle(); 77 | 78 | std::vector *GetReferenceToTimeTickVector(); 79 | 80 | double GetCurrentTime(); 81 | 82 | //function to call in timer loop, variable to manipulate gets changed here 83 | virtual void FunctionToCallInPlayState(); 84 | virtual void FunctionToCallInPauseState(); 85 | virtual void FunctionToCallInRewindState(); 86 | virtual void FunctionToCallInFastForwardState(); 87 | virtual void FunctionToCallInNullState(); 88 | 89 | void SetFunctionToCallAfterVariableChange(std::function < void() > thisFunction); 90 | 91 | void render(wxDC& dc); 92 | void logic_left_click(); 93 | void logic_right_click(); 94 | 95 | 96 | //function to return input file path 97 | std::string GetInputSoundFilePath(); 98 | 99 | //function to load audio from a given path 100 | void LoadAudioFromFileToTrack(std::string path); 101 | 102 | private: 103 | 104 | AudioTrack* m_left_channel_track; 105 | AudioTrack* m_right_channel_track; 106 | 107 | //state of audio track 108 | int track_state; 109 | 110 | ALuint* sourceToManipulatePtr; 111 | OpenALSoftPlayer* audioPlayerPtr; 112 | 113 | //options for track 114 | int track_options; 115 | 116 | double verticalStart; //vertical axis start 117 | double verticalEnd; //vertical axis end 118 | double verticalResolution; 119 | int verticalNumTicks; //number of tick marks in vertical axis 120 | 121 | std::function < void() > func_after_var_change; 122 | 123 | wxButton* browseButton; 124 | void OnBrowse(wxCommandEvent& event); 125 | 126 | std::string inputSoundFilePath; 127 | std::string streamSoundFilePath; 128 | 129 | void al_nssleep(unsigned long nsec); 130 | 131 | PlaybackControls* playbackControlsPtr; 132 | 133 | 134 | 135 | }; 136 | 137 | #endif 138 | -------------------------------------------------------------------------------- /include/listener.h: -------------------------------------------------------------------------------- 1 | #ifndef LISTENER_H 2 | #define LISTENER_H 3 | 4 | #include "AL/al.h" //header for OpenAL Soft 5 | #include "AL/alc.h" //header for OpenAL Soft 6 | #include "AL/alext.h" //header for OpenAL Soft 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include //for object to render on screen 15 | #include //for matrix transform that moves object rendered 16 | #include //for object rendered to be moved on screen by matrix transform 17 | 18 | 19 | 20 | //This is a class that holds positional info on object 21 | //as well as source and buffer components for use with OpenALSoftAudioEngine 22 | 23 | //DOES NOT PLAY SOUND. OpenALSoftAudioEngine plays the sound. 24 | //It only holds information to pass to OpenALSoftAudioEngine to play sound. 25 | 26 | struct ListenerSaveData 27 | { 28 | bool freeRoam; 29 | bool externalOrientation; 30 | }; 31 | 32 | class Listener 33 | { 34 | public: 35 | Listener(); 36 | ~Listener(); 37 | 38 | 39 | //Listener Position Functions 40 | 41 | void setPositionX(float& x); //set x position of listener 42 | float getPositionX(); //get x position of listener 43 | void setPositionY(float& y); //set y position of listener 44 | float getPositionY(); //get y position of listener 45 | void setPositionZ(float& z); //set z position of listener 46 | float getPositionZ(); //get z position of listener 47 | 48 | void MoveUp(float& distance); 49 | void MoveDown(float& distance); 50 | void MoveForward(float& distance); 51 | void MoveBack(float& distance); 52 | void MoveLeft(float& distance); 53 | void MoveRight(float& distance); 54 | 55 | void SetListenerFreeRoamBool(bool thisBool); 56 | bool GetListenerFreeRoamBool(); 57 | 58 | //Listener Orientation Functions 59 | void setForwardX(float& x); //set x of forward of listener 60 | float getForwardX(); //get x of forward of listener 61 | void setForwardY(float& y); //set y of forward of listener 62 | float getForwardY(); //get y of forward of listener 63 | void setForwardZ(float& z); //set z of forward of listener 64 | float getForwardZ(); //get z of forward listener 65 | 66 | void setUpX(float& x); //set x of up of listener 67 | float getUpX(); //get x of up of listener 68 | void setUpY(float& y); //set y of up of listener 69 | float getUpY(); //get y of up of listener 70 | void setUpZ(float& z); //set z of up of listener 71 | float getUpZ(); //get z of up of listener 72 | 73 | void SetWholeOrientation(float& fx, float& fy, float& fz, float& ux, float& uy, float& uz); 74 | 75 | void SetListenerExternalDeviceOrientationBool(bool thisBool); 76 | bool GetListenerExternalDeviceOrientationBool(); 77 | 78 | osg::ShapeDrawable* getRenderObject(); 79 | 80 | osg::Geode* getGeodeNode(); 81 | 82 | osg::PositionAttitudeTransform* getTransformNode(); 83 | 84 | ListenerSaveData GetListenerSaveData(); 85 | void LoadListenerSaveData(ListenerSaveData& data); 86 | 87 | private: 88 | //bool to indicate if the listener position can be changed freely by user or by listener track 89 | bool freeRoamByUser; 90 | 91 | //bool to indicate if the listener orientation can be changed by an external device or by listener track 92 | bool orientationByExternalDevice; 93 | 94 | void initListener(); 95 | 96 | //position of Listener 97 | std::vector listener_position_vector; 98 | enum POSITION_INDEX { X=0,Y=1,Z=2 }; 99 | void setListenerPosition(); //function to set listener position based on listener position vector coordinates 100 | 101 | //orientation of Listener 102 | std::vector listener_orientation_vector; //vector to hold values of listener orientation 103 | //first 3 values are forward vector xyz , last 3 values are up vector xyz 104 | //enum to help set orientation vector 105 | enum ORIENTATION_INDEX { FORWARD_X=0,FORWARD_Y=1,FORWARD_Z=2, 106 | UP_X=3, UP_Y=4, UP_Z=5 }; 107 | void setListenerOrientation(); //function to set listener orientation based on listener orientation vector coordinates 108 | 109 | //ShapeDrawable object to render 110 | osg::ref_ptr m_renderObject; 111 | 112 | osg::ref_ptr m_box; 113 | 114 | //holds geometry information for rendering, moved by transform of matrix 115 | osg::ref_ptr m_geode; 116 | 117 | //moves the geode 118 | osg::ref_ptr m_paTransform; 119 | 120 | ListenerSaveData m_saveData; 121 | }; 122 | 123 | #endif 124 | -------------------------------------------------------------------------------- /src/timeline-track-editor/include/audio-track.h: -------------------------------------------------------------------------------- 1 | #ifndef AUDIO_TRACK_H 2 | #define AUDIO_TRACK_H 3 | 4 | #include "track.h" 5 | #include "audio-graph.h" 6 | 7 | #include 8 | 9 | #include "openalsoft-player.h" 10 | 11 | #include // std::function, std::negate 12 | 13 | #include "audio-stream-container.h" 14 | 15 | #include "playback-controls.h" 16 | 17 | #define BUFFER_LEN 1024 18 | 19 | #define MAX_CHANNELS 2 20 | 21 | //Class used to manipulate placement of audio samples in timeline. 22 | //Used as helper class for StereoAudioTrack and MonoAudioTrack 23 | 24 | class AudioTrack : public Track 25 | { 26 | 27 | public: 28 | AudioTrack(const wxString& title); 29 | 30 | //Audio related functions 31 | void SetReferenceToSourceToManipulate(ALuint* thisSource); 32 | void SetReferenceToAudioPlayer(OpenALSoftPlayer* thisPlayer); 33 | 34 | int GetNumberOfChannelsInAudioFile(std::string path,SF_INFO& input_sfinfo); 35 | 36 | 37 | void ReadAndCopyDataFromInputFile(std::vector *audio_data_input_copy_ptr,std::string inputSoundFilePath,SF_INFO& input_sfinfo); 38 | 39 | void CopyInputDataIntoAudioDataStream(std::vector *audio_data_input_copy_ptr, AudioStreamContainer* audio_data_stream_ptr,std::string streamSoundFilePath,SF_INFO& input_sfinfo); 40 | 41 | void PlotOneChannelStreamAudioDataToGraph(AudioStreamContainer* audio_data_stream_ptr,SF_INFO& input_sfinfo); 42 | void PlotLeftChannelStreamAudioDataToGraph(AudioStreamContainer* audio_data_stream_ptr,SF_INFO& input_sfinfo); 43 | void PlotRightChannelStreamAudioDataToGraph(AudioStreamContainer* audio_data_stream_ptr,SF_INFO& input_sfinfo); 44 | 45 | //Track related Functions 46 | virtual void InitTrack(wxWindow* parent, std::vector *timeTickVector); 47 | 48 | //function to set bounds for variable to change as well as number of ticks to draw 49 | virtual void SetupAxisForVariable(double& start, double& end, double& resolution, int& numTick); 50 | 51 | virtual void OnPaint(wxPaintEvent& event); 52 | virtual void OnScroll(wxScrollEvent& event); 53 | virtual void OnSize(wxSizeEvent& event); 54 | 55 | virtual void OnLeftMouseClick(wxMouseEvent& event); 56 | virtual void OnRightMouseClick(wxCommandEvent& event); 57 | 58 | void SetReferenceToCurrentTimeVariable(double* thisTimeVariable); 59 | 60 | void SetReferenceToTimeTickVector(std::vector *thisVector); 61 | std::vector *GetReferenceToTimeTickVector(); 62 | 63 | void SetReferenceToPlaybackControls(PlaybackControls* controls); 64 | PlaybackControls* GetReferenceToPlaybackControls(); 65 | 66 | void SetTitle(wxString thisTitle); 67 | wxString GetTitle(); 68 | 69 | double GetCurrentTime(); 70 | 71 | virtual void FunctionToCallInPlayState(); 72 | virtual void FunctionToCallInPauseState(); 73 | virtual void FunctionToCallInRewindState(); 74 | virtual void FunctionToCallInFastForwardState(); 75 | virtual void FunctionToCallInNullState(); 76 | 77 | void SetFunctionToCallAfterVariableChange(std::function < void() > thisFunction); 78 | 79 | void render(wxDC& dc); 80 | void logic_left_click(); 81 | void logic_right_click(); 82 | 83 | enum State 84 | { 85 | PLAYER_NULL = 0, 86 | PLAYER_PLAYING, 87 | PLAYER_PAUSED, 88 | PLAYER_REWINDING 89 | }; 90 | 91 | void SetAudioTrackState(int thisState); 92 | int GetAudioTrackState(); 93 | 94 | void ClearGraph(); 95 | 96 | private: 97 | 98 | //Audio Processes and Operations 99 | 100 | //state of audio track 101 | int track_state; 102 | 103 | //source to manipulate 104 | ALuint* sourceToManipulatePtr; 105 | 106 | //pointer to audio player to use 107 | OpenALSoftPlayer* audioPlayerPtr; 108 | 109 | 110 | //File handlers for input file and file to stream 111 | SNDFILE *inputFile; 112 | 113 | 114 | //GUI 115 | 116 | std::vector m_vertical_var_num; 117 | void InitVerticalAxis(); 118 | std::vector LinearSpacedArray(double a, double b, std::size_t N); 119 | 120 | double verticalStart; //vertical axis start 121 | double verticalEnd; //vertical axis end 122 | double verticalResolution; 123 | int verticalNumTicks; //number of tick marks in vertical axis 124 | 125 | AudioGraph* m_audio_graph; 126 | 127 | std::function < void() > func_after_var_change; 128 | 129 | void al_nssleep(unsigned long nsec); 130 | 131 | PlaybackControls* playbackControlsPtr; 132 | }; 133 | 134 | #endif 135 | -------------------------------------------------------------------------------- /include/soundproducer-track.h: -------------------------------------------------------------------------------- 1 | #ifndef SOUND_PRODUCER_TRACK_H 2 | #define SOUND_PRODUCER_TRACK_H 3 | 4 | 5 | #include "double-track.h" 6 | 7 | #include "stereo-audio-track.h" 8 | 9 | #include 10 | #include 11 | 12 | #include 13 | 14 | #include "soundproducer-registry.h" 15 | #include "soundproducer.h" 16 | 17 | struct SoundProducerTrackSaveData 18 | { 19 | //name of sound producer 20 | std::string soundproducer_name; 21 | 22 | //double track save data 23 | DDMap* time_value_map_x_ptr; 24 | DDMap* time_value_map_y_ptr; 25 | DDMap* time_value_map_z_ptr; 26 | 27 | //file name of sound file 28 | std::string soundfilepath; 29 | }; 30 | 31 | //class to manipulate x,y z position of sound producer 32 | class SoundProducerTrack : public Track 33 | { 34 | public: 35 | SoundProducerTrack(const wxString& title,ALCdevice* thisAudioDevice,ALCcontext* thisAudioContext); 36 | ~SoundProducerTrack(); 37 | 38 | StereoAudioTrack* GetReferenceToStereoAudioTrack(); 39 | DoubleTrack* GetReferenceToXTrack(); 40 | DoubleTrack* GetReferenceToYTrack(); 41 | DoubleTrack* GetReferenceToZTrack(); 42 | 43 | void BufferAndPlayAudio(double& current_time); 44 | void StopAudio(); 45 | 46 | //functions to set reference to audio device and audio context to use for player 47 | void SetReferenceToAudioDevice(ALCdevice* thisAudioDevice); 48 | void SetReferenceToAudioContext(ALCcontext* thisAudioContext); 49 | 50 | //SoundProducer Editing 51 | void SetReferenceToSoundProducerToManipulate(SoundProducer* thisSoundProducer); 52 | void SetReferenceToSoundProducerRegistry(SoundProducerRegistry* thisRegistry); 53 | 54 | void UpdateComboBoxListFromSoundProducerRegistry(); 55 | 56 | wxComboBox* GetReferenceToComboBox(); 57 | 58 | //audio track related functions 59 | void SetupAxisForAudio(double& start, double& end,double& resolution, int& numTick); 60 | void SetReferenceToPlaybackControls(PlaybackControls* controls); 61 | 62 | //Double Track related functions 63 | void SetupAxisForVariable(double& start, double& end, double& resolution, int& numTick); 64 | 65 | void OnLeftMouseClick(wxMouseEvent& event); 66 | void OnRightMouseClick(wxCommandEvent& event); 67 | 68 | //Functions inherited from Track 69 | virtual void InitTrack(wxWindow* parent, std::vector *timeTickVector); 70 | 71 | virtual void OnPaint(wxPaintEvent& event); 72 | virtual void OnScroll(wxScrollEvent& event); 73 | virtual void OnSize(wxSizeEvent& event); 74 | 75 | void SetReferenceToCurrentTimeVariable(double* thisTimeVariable); 76 | void SetReferenceToTimeTickVector(std::vector *thisVector); 77 | 78 | std::vector *GetReferenceToTimeTickVector(); 79 | 80 | double GetCurrentTime(); 81 | 82 | //function to call in timer loop, variable to manipulate gets changed here 83 | virtual void FunctionToCallInPlayState(); 84 | virtual void FunctionToCallInPauseState(); 85 | virtual void FunctionToCallInRewindState(); 86 | virtual void FunctionToCallInFastForwardState(); 87 | virtual void FunctionToCallInNullState(); 88 | 89 | //functions to return reference to track source and sound producer manipulated by soundproducer track 90 | //for use with effects manager 91 | ALuint* GetReferenceToTrackSource(); 92 | SoundProducer* GetReferenceToSoundProducerManipulated(); 93 | bool IsReverbApplied(); 94 | void SetStatusReverbApplied(bool status); 95 | 96 | //Audio DAW 97 | void SetReferenceToImportAudioDAWButton(wxButton* thisButton); 98 | 99 | SoundProducerTrackSaveData GetSoundProducerTrackSaveData(); 100 | void LoadSoundProducerTrackSaveData(SoundProducerTrackSaveData& data); 101 | 102 | void SelectSoundProducerByName(std::string name); 103 | 104 | void SetComboBoxToThisSelectionName(std::string name); 105 | 106 | friend class SoundProducerTrackManager; 107 | 108 | private: 109 | SoundProducer* soundProducerToManipulatePtr; 110 | 111 | OpenALSoftPlayer* audioPlayer; 112 | 113 | ALCdevice* audioDevicePtr; //pointer to audio device to be used 114 | ALCcontext* alContextPtr; //pointer to context of where audio is played 115 | 116 | StereoAudioTrack* audioTrack; 117 | DoubleTrack* xTrack; 118 | DoubleTrack* yTrack; 119 | DoubleTrack* zTrack; 120 | 121 | //variables to hold temporary values for sound producer position 122 | double tempX,tempY,tempZ; 123 | 124 | //source to play buffer 125 | ALuint track_source; 126 | 127 | wxComboBox* m_combo_box; 128 | 129 | SoundProducerRegistry* soundproducer_registry_ptr; 130 | 131 | void OnSelectedSoundProducerInComboBox(wxCommandEvent& event); 132 | 133 | 134 | //bool to tell if reverb is applied to the source of the track 135 | bool reverbApplied; 136 | 137 | //button for using the DAW audio import plugin for binaural audio editor 138 | wxButton* m_importAudioDAWButton; 139 | 140 | void OnImportAudioDAWButtonClick(wxCommandEvent& event); 141 | 142 | std::string streamSoundFilePath; 143 | 144 | SoundProducerTrackSaveData m_saveData; 145 | }; 146 | 147 | #endif 148 | -------------------------------------------------------------------------------- /src/setup-serial-dialog.cpp: -------------------------------------------------------------------------------- 1 | // For compilers that support precompilation, includes "wx.h". 2 | #include "wx/wxprec.h" 3 | 4 | #ifdef __BORLANDC__ 5 | #pragma hdrstop 6 | #endif 7 | 8 | #ifdef WIN32 9 | #include 10 | #endif 11 | 12 | #ifndef WX_PRECOMP 13 | #include "wx/wx.h" 14 | #endif 15 | 16 | 17 | #include "setup-serial-dialog.h" 18 | 19 | 20 | SetupSerialDialog::SetupSerialDialog(const wxString & title, ListenerExternal* listenerext) 21 | : wxDialog(NULL, -1, title, wxDefaultPosition, wxSize(500, 250), wxRESIZE_BORDER) 22 | { 23 | 24 | SetupSerialDialog::initPrivateVariables(); 25 | 26 | //make horizontal box to put names in 27 | wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL); 28 | 29 | //make vertical box to put display info to edit 30 | wxBoxSizer *vboxEdit = new wxBoxSizer(wxVERTICAL); 31 | 32 | 33 | //initialize text field for path to serial port 34 | textFieldSerialPort = new wxTextCtrl(this,-1, "Serial Port here",wxPoint(95, 20), wxSize(80,20),wxTE_PROCESS_ENTER); 35 | textFieldSerialPort->Clear(); 36 | wxStaticText* serialPortText = new wxStaticText(this, -1, wxT("Serial Port :"), wxPoint(40, 60)); 37 | 38 | //initialize setup button 39 | setupButton = new wxButton(this, wxID_ANY, wxT("Setup"), wxDefaultPosition, wxSize(70, 30) ); 40 | setupButton->Bind(wxEVT_BUTTON, &SetupSerialDialog::OnSetup,this); 41 | 42 | //add textfield to edit box 43 | vboxEdit->Add(serialPortText, 1 , wxEXPAND | wxALL, 1); 44 | vboxEdit->Add(textFieldSerialPort, 1 , wxEXPAND | wxALL, 1); 45 | vboxEdit->Add(setupButton, 1 , wxEXPAND | wxALL, 1); 46 | 47 | hbox->Add(vboxEdit, 1, wxEXPAND | wxALL, 10); 48 | 49 | 50 | //initialize Ok and Cancel buttons 51 | okButton = new wxButton(this, wxID_ANY, wxT("Ok"), wxDefaultPosition, wxSize(70, 30) ); 52 | okButton->Bind(wxEVT_BUTTON, &SetupSerialDialog::OnOk,this); 53 | 54 | cancelButton = new wxButton(this, wxID_ANY, wxT("Cancel"), wxDefaultPosition, wxSize(70, 30) ); 55 | cancelButton->Bind(wxEVT_BUTTON, &SetupSerialDialog::OnCancel,this); 56 | 57 | 58 | 59 | //make horizontal box to put ok and cancel buttons in 60 | wxBoxSizer *hboxBottom = new wxBoxSizer(wxHORIZONTAL); 61 | 62 | hboxBottom->Add(okButton, 0); 63 | hboxBottom->Add(cancelButton, 0, wxLEFT, 5); 64 | 65 | //Make vertical box to put everything in 66 | wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL); 67 | 68 | //add panel of text fields in vertical box 69 | vbox->Add(hbox, 1, wxEXPAND | wxALL, 10); 70 | vbox->Add(hboxBottom, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, 10); 71 | 72 | SetSizerAndFit(vbox); 73 | 74 | //update position text fields and checkbox to have current properties of listener 75 | ptrListenerExternal = listenerext; 76 | if(ptrListenerExternal == nullptr){std::cout << "listener external pointer is nullptr! \n";} 77 | else 78 | { 79 | 80 | (*textFieldSerialPort) << ptrListenerExternal->GetSerialPortPath(); 81 | } 82 | 83 | //center and show elements in dialog 84 | Centre(); 85 | ShowModal(); 86 | 87 | //destroy when done showing 88 | Destroy(); 89 | } 90 | 91 | void SetupSerialDialog::initPrivateVariables() 92 | { 93 | ptrListenerExternal = nullptr; 94 | textFieldSerialPort = nullptr; 95 | 96 | setupButton = nullptr; okButton = nullptr; cancelButton = nullptr; 97 | } 98 | 99 | void SetupSerialDialog::ChangeListenerAttributes() 100 | { 101 | if(ptrListenerExternal != nullptr) 102 | { 103 | ptrListenerExternal->SetSerialPortPath(textFieldSerialPort->GetLineText(0).ToStdString()); 104 | } 105 | 106 | } 107 | 108 | void SetupSerialDialog::OnSetup(wxCommandEvent& event) 109 | { 110 | if(ptrListenerExternal != nullptr) 111 | { 112 | if( textFieldSerialPort->GetLineText(0).ToStdString() != " " ) 113 | { 114 | if(!ptrListenerExternal->GetExternalOrientationSerialDevicePtr()->GetDeviceInitializedBool()) 115 | { 116 | ptrListenerExternal->SetSerialPortPath(textFieldSerialPort->GetLineText(0).ToStdString()); 117 | ptrListenerExternal->GetExternalOrientationSerialDevicePtr()->InitSerialCommunication(textFieldSerialPort->GetLineText(0).ToStdString(),9600); 118 | 119 | if(ptrListenerExternal->GetExternalOrientationSerialDevicePtr()->GetDeviceInitializedBool()) 120 | { 121 | wxMessageBox(wxT("Successfully setup serial communication! \n")); 122 | } 123 | else 124 | { 125 | //wxString thisString(message); 126 | wxMessageBox(wxT("Failed to setup serial communication! \n")); 127 | } 128 | 129 | } 130 | } 131 | 132 | } 133 | } 134 | 135 | void SetupSerialDialog::OnOk(wxCommandEvent& event ) 136 | { 137 | SetupSerialDialog::ChangeListenerAttributes(); 138 | 139 | SetupSerialDialog::Exit(); 140 | } 141 | 142 | void SetupSerialDialog::OnCancel(wxCommandEvent& event) 143 | { 144 | SetupSerialDialog::Exit(); 145 | } 146 | 147 | void SetupSerialDialog::Exit() 148 | { 149 | if(okButton != nullptr){ delete okButton;} 150 | if(setupButton != nullptr){delete setupButton;} 151 | if(cancelButton != nullptr){delete cancelButton;} 152 | if(textFieldSerialPort != nullptr){delete textFieldSerialPort;} 153 | Close( true ); //close window 154 | } 155 | 156 | 157 | -------------------------------------------------------------------------------- /src/soundproducer-track-manager.cpp: -------------------------------------------------------------------------------- 1 | #include "soundproducer-track-manager.h" 2 | 3 | SoundProducerTrackManager::SoundProducerTrackManager(const wxString& title,ALCdevice* thisAudioDevice,ALCcontext* thisAudioContext) : Track(title) 4 | { 5 | //initialize audio player 6 | audioPlayer = new OpenALSoftPlayer(); 7 | audioPlayer->SetReferenceToAudioContext(thisAudioContext); 8 | audioPlayer->SetReferenceToAudioDevice(thisAudioDevice); 9 | 10 | soundProducerTracks_vec = nullptr; 11 | 12 | SoundProducerTrackManager::SetSoundPlayingBool(false); 13 | } 14 | 15 | SoundProducerTrackManager::~SoundProducerTrackManager() 16 | { 17 | if(audioPlayer != nullptr) 18 | { 19 | delete audioPlayer; 20 | } 21 | } 22 | 23 | void SoundProducerTrackManager::SetReferenceToAudioDevice(ALCdevice* thisAudioDevice){audioDevicePtr = thisAudioDevice;} 24 | void SoundProducerTrackManager::SetReferenceToAudioContext(ALCcontext* thisAudioContext){alContextPtr = thisAudioContext;} 25 | 26 | void SoundProducerTrackManager::SetReferenceToSoundProducerTrackVector(std::vector *thisTrackVec) 27 | { 28 | soundProducerTracks_vec = thisTrackVec; 29 | } 30 | 31 | void SoundProducerTrackManager::AddSourceOfLastTrackToSoundProducerTrackManager() 32 | { 33 | if(soundProducerTracks_vec != nullptr) 34 | { 35 | ALuint* thisSource = soundProducerTracks_vec->at(soundProducerTracks_vec->size() - 1)->GetReferenceToTrackSource(); 36 | soundproducertracks_sources_vector.push_back(thisSource); 37 | } 38 | 39 | } 40 | void SoundProducerTrackManager::RemoveSourceOfLastTrackFromSoundProducerTrackManager() 41 | { 42 | soundproducertracks_sources_vector.pop_back(); 43 | } 44 | 45 | //Functions inherited from Track 46 | 47 | 48 | 49 | void SoundProducerTrackManager::SetReferenceToCurrentTimeVariable(double* thisTimeVariable){Track::SetReferenceToCurrentTimeVariable(thisTimeVariable);} 50 | 51 | double SoundProducerTrackManager::GetCurrentTime(){return Track::GetCurrentTime();} 52 | 53 | 54 | //function to call in timer loop, variable to manipulate gets changed here 55 | void SoundProducerTrackManager::FunctionToCallInPlayState() 56 | { 57 | SoundProducerTrackManager::SetSoundPlayingBool(true); 58 | 59 | //buffer audio for all track sources 60 | for(size_t i=0; i < soundProducerTracks_vec->size(); i++) 61 | { 62 | soundProducerTracks_vec->at(i)->FunctionToCallInPlayState(); 63 | } 64 | 65 | //play all sources in sync 66 | if(soundProducerTracks_vec->at(0)->GetReferenceToStereoAudioTrack()->GetAudioTrackState() == StereoAudioTrack::State::PLAYER_NULL) 67 | { 68 | audioPlayer->PlayMultipleSources(&soundproducertracks_sources_vector); 69 | } 70 | else if(soundProducerTracks_vec->at(0)->GetReferenceToStereoAudioTrack()->GetAudioTrackState() == StereoAudioTrack::State::PLAYER_PLAYING) 71 | { 72 | audioPlayer->PlayMultipleUpdatedPlayerBuffers(&soundproducertracks_sources_vector); 73 | } 74 | } 75 | 76 | void SoundProducerTrackManager::FunctionToCallInPauseState() 77 | { 78 | SoundProducerTrackManager::SetSoundPlayingBool(false); 79 | 80 | for(size_t i=0; i < soundProducerTracks_vec->size(); i++) 81 | { 82 | soundProducerTracks_vec->at(i)->FunctionToCallInPauseState(); 83 | } 84 | } 85 | 86 | void SoundProducerTrackManager::FunctionToCallInRewindState() 87 | { 88 | SoundProducerTrackManager::SetSoundPlayingBool(false); 89 | 90 | for(size_t i=0; i < soundProducerTracks_vec->size(); i++) 91 | { 92 | soundProducerTracks_vec->at(i)->FunctionToCallInRewindState(); 93 | } 94 | } 95 | 96 | void SoundProducerTrackManager::FunctionToCallInFastForwardState() 97 | { 98 | SoundProducerTrackManager::SetSoundPlayingBool(false); 99 | 100 | for(size_t i=0; i < soundProducerTracks_vec->size(); i++) 101 | { 102 | soundProducerTracks_vec->at(i)->FunctionToCallInFastForwardState(); 103 | } 104 | } 105 | 106 | void SoundProducerTrackManager::FunctionToCallInNullState() 107 | { 108 | SoundProducerTrackManager::SetSoundPlayingBool(false); 109 | 110 | for(size_t i=0; i < soundProducerTracks_vec->size(); i++) 111 | { 112 | soundProducerTracks_vec->at(i)->FunctionToCallInNullState(); 113 | } 114 | } 115 | 116 | void SoundProducerTrackManager::SetSoundPlayingBool(bool status){soundPlaying = status;} 117 | 118 | bool SoundProducerTrackManager::IsSoundBeingPlayed(){return soundPlaying;} 119 | 120 | void SoundProducerTrackManager::PlayThisTrackFromSoundProducerTrackVector(int& index) 121 | { 122 | //buffer audio for track source 123 | //soundProducerTracks_vec->at(index)->FunctionToCallInPlayState(); 124 | 125 | double current_time = 0; 126 | 127 | soundProducerTracks_vec->at(index)->BufferAndPlayAudio(current_time); 128 | 129 | } 130 | 131 | void SoundProducerTrackManager::PauseThisTrackFromSoundProducerTrackVector(int& index) 132 | { 133 | audioPlayer->PauseSource(soundproducertracks_sources_vector[index]); 134 | } 135 | 136 | void SoundProducerTrackManager::StopThisTrackFromSoundProducerTrackVector(int& index) 137 | { 138 | soundProducerTracks_vec->at(index)->StopAudio(); 139 | } 140 | 141 | void SoundProducerTrackManager::BrowseAudioForThisSoundProducer(SoundProducer* lastProducer) 142 | { 143 | //get sound producer name of last sound producer created 144 | soundProducerTracks_vec->back()->SelectSoundProducerByName(lastProducer->GetNameString()); 145 | 146 | soundProducerTracks_vec->back()->GetReferenceToStereoAudioTrack()->BrowseForInputAudioFile(); 147 | } 148 | -------------------------------------------------------------------------------- /src/external-orientation-device-serial.cpp: -------------------------------------------------------------------------------- 1 | // For compilers that support precompilation, includes "wx.h". 2 | #include "wx/wxprec.h" 3 | 4 | #ifdef __BORLANDC__ 5 | #pragma hdrstop 6 | #endif 7 | 8 | #ifdef WIN32 9 | #include 10 | #endif 11 | 12 | #ifndef WX_PRECOMP 13 | #include "wx/wx.h" 14 | #endif 15 | 16 | #include "external-orientation-device-serial.h" 17 | 18 | ExternalOrientationDeviceSerial::ExternalOrientationDeviceSerial() 19 | { 20 | m_serial_ptr = nullptr; 21 | deviceInitialized = false; 22 | 23 | forward_vector_quaternion = boost::math::quaternion (0,0,0,-1); 24 | up_vector_quaternion = boost::math::quaternion (0,0,1,0); 25 | } 26 | 27 | ExternalOrientationDeviceSerial::~ExternalOrientationDeviceSerial() 28 | { 29 | if(m_serial_ptr != nullptr) 30 | { 31 | delete m_serial_ptr; 32 | } 33 | } 34 | 35 | void ExternalOrientationDeviceSerial::InitSerialCommunication(std::string port,unsigned int baud_rate) 36 | { 37 | try 38 | { 39 | m_serial_ptr = new SimpleSerial(port,baud_rate); 40 | 41 | if(m_serial_ptr != nullptr) 42 | { 43 | ExternalOrientationDeviceSerial::SetDeviceInitializedBool(true); 44 | } 45 | } 46 | catch(boost::system::system_error& e) 47 | { 48 | std::cout<< "Error: " << e.what() << std::endl; 49 | m_serial_ptr = nullptr; 50 | ExternalOrientationDeviceSerial::SetDeviceInitializedBool(false); 51 | } 52 | } 53 | 54 | void ExternalOrientationDeviceSerial::SetDeviceInitializedBool(bool status){deviceInitialized = status;} 55 | 56 | bool ExternalOrientationDeviceSerial::GetDeviceInitializedBool(){return deviceInitialized;} 57 | 58 | void ExternalOrientationDeviceSerial::ReadOrientationParametersFromSerial(float* fx,float* fy, float* fz, 59 | float* ux, float* uy,float* uz) 60 | { 61 | std::vector results; 62 | std::cout << "In read orientation parameters. \n"; 63 | //read line 64 | //std::string quaternion_data = m_serial_ptr->readLine(); 65 | 66 | //std::cout << "quaternion data: \n" << quaternion_data << std::endl; 67 | std::string quaternion_data; 68 | 69 | //get rotation quaternion w 70 | m_serial_ptr->writeString("!"); //send command to display quaternion w 71 | quaternion_data = m_serial_ptr->readLine(); //read number 72 | m_serial_ptr->writeString("%"); //send command to stop display 73 | float w = std::stof(quaternion_data); 74 | 75 | //std::cout << "\n quaternion data w:" << quaternion_data << std::endl; 76 | 77 | //get rotation quaternion x 78 | m_serial_ptr->writeString("@"); //send command to display quaternion x 79 | quaternion_data = m_serial_ptr->readLine(); //read number 80 | m_serial_ptr->writeString("%"); //send command to stop display 81 | float x = std::stof(quaternion_data); 82 | 83 | //std::cout << "\n quaternion data x:" << quaternion_data << std::endl; 84 | 85 | //get rotation quaternion y 86 | m_serial_ptr->writeString("#"); //send command to display quaternion y 87 | quaternion_data = m_serial_ptr->readLine(); //read number 88 | m_serial_ptr->writeString("%"); //send command to stop display 89 | float y = std::stof(quaternion_data); 90 | 91 | //std::cout << "\n quaternion data y:" << quaternion_data << std::endl; 92 | 93 | //get rotation quaternion z 94 | m_serial_ptr->writeString("$"); //send command to display quaternion z 95 | quaternion_data = m_serial_ptr->readLine(); //read number 96 | m_serial_ptr->writeString("%"); //send command to stop display 97 | float z = std::stof(quaternion_data); 98 | 99 | //std::cout << "\n quaternion data z:" << quaternion_data << std::endl; 100 | 101 | 102 | boost::math::quaternion rotation_quaternion(w,x,y,z); 103 | boost::math::quaternion inverse_rotation_quaternion(w,-1*x,-1*y,-1*z); 104 | 105 | 106 | //calculate new rotated forward vector 107 | // P'= R*P*R' 108 | boost::math::quaternion rotated_forward_vector_quaternion; 109 | rotated_forward_vector_quaternion = rotation_quaternion * forward_vector_quaternion * inverse_rotation_quaternion; 110 | 111 | boost::math::quaternion rotated_up_vector_quaternion; 112 | rotated_up_vector_quaternion = rotation_quaternion * up_vector_quaternion * inverse_rotation_quaternion; 113 | 114 | //remap values for binaural audio editor 115 | //y in binaural audio editor = z in regular cartesian 116 | //x in binaural audio editor = y in regular cartesian 117 | //z in binaural audio editor = x in regular cartesian 118 | *fz = rotated_up_vector_quaternion.R_component_2(); 119 | 120 | *fx = rotated_up_vector_quaternion.R_component_4(); 121 | 122 | *fy = rotated_up_vector_quaternion.R_component_3(); 123 | 124 | *uz = rotated_forward_vector_quaternion.R_component_2(); 125 | 126 | *ux = rotated_forward_vector_quaternion.R_component_4(); 127 | 128 | *uy = rotated_forward_vector_quaternion.R_component_3(); 129 | 130 | } 131 | 132 | ExternalDeviceRepeatTimer::ExternalDeviceRepeatTimer(ExternalOrientationDeviceSerial* device, Listener* listener) : wxTimer() 133 | { 134 | m_device = device; 135 | m_listener_ptr = listener; 136 | reading_values = false; 137 | } 138 | 139 | void ExternalDeviceRepeatTimer::Notify() 140 | { 141 | if(!ExternalDeviceRepeatTimer::GetReadingValuesBool()) 142 | { 143 | ExternalDeviceRepeatTimer::FunctionToRepeat(); 144 | } 145 | } 146 | 147 | void ExternalDeviceRepeatTimer::FunctionToRepeat() 148 | { 149 | 150 | } 151 | 152 | void ExternalDeviceRepeatTimer::start() 153 | { 154 | wxTimer::Start(400,wxTIMER_CONTINUOUS); //the timer calls Notify every 250 milliseconds 155 | } 156 | 157 | void ExternalDeviceRepeatTimer::SetReadingValuesBool(bool state){reading_values = state;} 158 | bool ExternalDeviceRepeatTimer::GetReadingValuesBool(){return reading_values;} 159 | -------------------------------------------------------------------------------- /src/soundproducer-registry.cpp: -------------------------------------------------------------------------------- 1 | // For compilers that support precompilation, includes "wx.h". 2 | #include "wx/wxprec.h" 3 | 4 | #ifdef __BORLANDC__ 5 | #pragma hdrstop 6 | #endif 7 | 8 | #ifdef WIN32 9 | #include 10 | #endif 11 | 12 | #ifndef WX_PRECOMP 13 | #include "wx/wx.h" 14 | #endif 15 | 16 | #include "soundproducer-registry.h" 17 | 18 | 19 | void SoundProducerRegistry::SetReferenceToSoundProducerVector(std::vector > *sound_producer_vector) 20 | { 21 | sound_producer_vector_ref = sound_producer_vector; 22 | } 23 | 24 | SoundProducer* SoundProducerRegistry::GetPointerToSoundProducerWithThisName(std::string thisName) 25 | { 26 | //get iterator to sound producers vector from soundproducers map 27 | //std::unordered_map >::iterator>::const_iterator got = map_soundproducer.find (thisName); 28 | std::unordered_map::const_iterator got = map_soundproducer.find (thisName); 29 | 30 | //std::vector >::iterator it = got->second; 31 | size_t index = got->second; 32 | 33 | //return it->get(); 34 | return sound_producer_vector_ref->at(index).get(); 35 | } 36 | 37 | wxArrayString& SoundProducerRegistry::GetSoundProducersToEditList(){return soundproducers_to_edit_wxstring;} 38 | 39 | void SoundProducerRegistry::AddRecentSoundProducerMadeToRegistry() 40 | { 41 | if(sound_producer_vector_ref != nullptr) 42 | { 43 | //std::cout << "Add recent sound producer made to track called! \n"; 44 | 45 | 46 | SoundProducer* thisSoundProducer = nullptr; 47 | //std::vector >::iterator it; 48 | size_t index = 0; 49 | 50 | if(sound_producer_vector_ref->size() >= 1) 51 | { 52 | thisSoundProducer = sound_producer_vector_ref->at(sound_producer_vector_ref->size() - 1).get(); 53 | //it = sound_producer_vector_ref->end() - 1; 54 | index = sound_producer_vector_ref->size() - 1; 55 | 56 | if(thisSoundProducer != nullptr) 57 | { 58 | wxString thisString(thisSoundProducer->GetNameString()); 59 | 60 | soundproducers_to_edit_wxstring.Add(thisString); 61 | 62 | map_soundproducer.emplace(thisSoundProducer->GetNameString(),index); 63 | } 64 | } 65 | 66 | 67 | } 68 | 69 | } 70 | 71 | void SoundProducerRegistry::RemoveSoundProducerFromRegistry(SoundProducer* thisSoundProducer) 72 | { 73 | wxString thisString(thisSoundProducer->GetNameString()); 74 | soundproducers_to_edit_wxstring.Remove(thisString); 75 | 76 | //get index of sound producer to remove 77 | size_t index_to_rm = 0; 78 | std::unordered_map::const_iterator got = map_soundproducer.find (thisSoundProducer->GetNameString()); 79 | index_to_rm = got->second; 80 | 81 | //decrement index of all soundproducers after this index 82 | for ( auto it = map_soundproducer.begin(); it != map_soundproducer.end(); ++it ) 83 | { 84 | if(it->second > index_to_rm) 85 | { 86 | it->second--; 87 | } 88 | } 89 | 90 | //erase sound producer from map 91 | map_soundproducer.erase(thisSoundProducer->GetNameString()); 92 | 93 | } 94 | 95 | 96 | void SoundProducerRegistry::RemoveThisNameFromEditingList(std::string thisName) 97 | { 98 | soundproducers_to_edit_wxstring.Remove(thisName); 99 | } 100 | 101 | 102 | void SoundProducerRegistry::AddThisNameToEditingList(std::string thisName) 103 | { 104 | soundproducers_to_edit_wxstring.Add(thisName); 105 | } 106 | 107 | void SoundProducerRegistry::AddAllSoundProducersToEditingList() 108 | { 109 | if(sound_producer_vector_ref != nullptr) 110 | { 111 | soundproducers_to_edit_wxstring.Clear(); 112 | for(size_t i=0; i < sound_producer_vector_ref->size(); i++) 113 | { 114 | wxString thisString(sound_producer_vector_ref->at(i)->GetNameString()); 115 | 116 | soundproducers_to_edit_wxstring.Add(thisString); 117 | } 118 | } 119 | 120 | } 121 | 122 | void SoundProducerRegistry::AddReferenceToComboBox(wxComboBox* thisComboBox) 123 | { 124 | combo_box_ptr_vec.push_back(thisComboBox); 125 | } 126 | 127 | void SoundProducerRegistry::RemoveLastComboBoxReference() 128 | { 129 | combo_box_ptr_vec.pop_back(); 130 | } 131 | 132 | void SoundProducerRegistry::UpdateAllComboBoxesList() 133 | { 134 | for(size_t i=0; i < combo_box_ptr_vec.size(); i++) 135 | { 136 | wxString currentNameSelected = combo_box_ptr_vec[i]->GetStringSelection(); 137 | 138 | combo_box_ptr_vec[i]->Clear(); 139 | combo_box_ptr_vec[i]->Append(soundproducers_to_edit_wxstring); 140 | 141 | int select_index = combo_box_ptr_vec[i]->FindString(currentNameSelected,true); //case sensitive = true 142 | combo_box_ptr_vec[i]->SetSelection(select_index); 143 | } 144 | } 145 | 146 | void SoundProducerRegistry::RemoveThisNameFromAllComboBoxesExceptThisOne(std::string thisName, wxComboBox* thisComboBox) 147 | { 148 | SoundProducerRegistry::AddAllSoundProducersToEditingList(); 149 | 150 | SoundProducerRegistry::RemoveThisNameFromEditingList(thisName); 151 | 152 | for(size_t i=0; i < combo_box_ptr_vec.size(); i++) 153 | { 154 | if(combo_box_ptr_vec[i] != thisComboBox) 155 | { 156 | wxString currentSelectionString = combo_box_ptr_vec[i]->GetStringSelection(); 157 | 158 | combo_box_ptr_vec[i]->Clear(); 159 | combo_box_ptr_vec[i]->Append(soundproducers_to_edit_wxstring); 160 | 161 | int select_index = combo_box_ptr_vec[i]->FindString(currentSelectionString,true); //case sensitive = true 162 | combo_box_ptr_vec[i]->SetSelection(select_index); 163 | } 164 | } 165 | } 166 | 167 | void SoundProducerRegistry::ClearAllSoundproducerNames() 168 | { 169 | soundproducers_to_edit_wxstring.clear(); 170 | 171 | } 172 | 173 | void SoundProducerRegistry::ClearAll() 174 | { 175 | soundproducers_to_edit_wxstring.clear(); 176 | combo_box_ptr_vec.clear(); 177 | } 178 | -------------------------------------------------------------------------------- /include/reverb-zone.h: -------------------------------------------------------------------------------- 1 | #ifndef REVERB_ZONE_H 2 | #define REVERB_ZONE_H 3 | 4 | #include "effect-zone.h" 5 | 6 | struct ReverbEAXProperties 7 | { 8 | //AL_EAXREVERB_DENSITY, 9 | double flDensity; 10 | //AL_EAXREVERB_DIFFUSION, 11 | double flDiffusion; 12 | //AL_EAXREVERB_GAIN, 13 | double flGain; 14 | //AL_EAXREVERB_GAINHF, 15 | double flGainHF; 16 | //AL_EAXREVERB_GAINLF, 17 | double flGainLF; 18 | //AL_EAXREVERB_DECAY_TIME, 19 | double flDecayTime; 20 | //AL_EAXREVERB_DECAY_HFRATIO, 21 | double flDecayHFRatio; 22 | //AL_EAXREVERB_DECAY_LFRATIO, 23 | double flDecayLFRatio; 24 | //AL_EAXREVERB_REFLECTIONS_GAIN, 25 | double flReflectionsGain; 26 | //AL_EAXREVERB_REFLECTIONS_DELAY, 27 | double flReflectionsDelay; 28 | //alEffectfv(effect, AL_EAXREVERB_REFLECTIONS_PAN, double flReflectionsPan; 29 | //AL_EAXREVERB_LATE_REVERB_GAIN, 30 | double flLateReverbGain; 31 | //AL_EAXREVERB_LATE_REVERB_DELAY, 32 | double flLateReverbDelay; 33 | //alEffectfv(effect, AL_EAXREVERB_LATE_REVERB_PAN, double flLateReverbPan; 34 | //AL_EAXREVERB_ECHO_TIME, 35 | double flEchoTime; 36 | //AL_EAXREVERB_ECHO_DEPTH, 37 | double flEchoDepth; 38 | //AL_EAXREVERB_MODULATION_TIME, 39 | double flModulationTime; 40 | //AL_EAXREVERB_MODULATION_DEPTH, 41 | double flModulationDepth; 42 | //AL_EAXREVERB_HFREFERENCE, 43 | double flHFReference; 44 | //AL_EAXREVERB_LFREFERENCE, 45 | double flLFReference; 46 | //AL_EAXREVERB_AIR_ABSORPTION_GAINHF, 47 | double flAirAbsorptionGainHF; 48 | //AL_EAXREVERB_ROOM_ROLLOFF_FACTOR, 49 | double flRoomRolloffFactor; 50 | //AL_EAXREVERB_DECAY_HFLIMIT, 51 | //int iDecayHFLimit; 52 | }; 53 | 54 | struct EAXReverbZoneSaveData 55 | { 56 | //name 57 | std::string name; 58 | 59 | //position 60 | double x; 61 | double y; 62 | double z; 63 | 64 | //size 65 | double width; 66 | 67 | //properties 68 | ReverbEAXProperties properties; 69 | 70 | }; 71 | 72 | struct ReverbStandardProperties 73 | { 74 | //AL_REVERB_DENSITY, 75 | double flDensity; 76 | //AL_REVERB_DIFFUSION, 77 | double flDiffusion; 78 | //AL_REVERB_GAIN, 79 | double flGain; 80 | //AL_REVERB_GAINHF, 81 | double flGainHF; 82 | //AL_REVERB_DECAY_TIME, 83 | double flDecayTime; 84 | //AL_REVERB_DECAY_HFRATIO, 85 | double flDecayHFRatio; 86 | //AL_REVERB_REFLECTIONS_GAIN, 87 | double flReflectionsGain; 88 | //AL_REVERB_REFLECTIONS_DELAY, 89 | double flReflectionsDelay; 90 | //AL_REVERB_LATE_REVERB_GAIN, 91 | double flLateReverbGain; 92 | //AL_REVERB_LATE_REVERB_DELAY, 93 | double flLateReverbDelay; 94 | //AL_REVERB_AIR_ABSORPTION_GAINHF, 95 | double flAirAbsorptionGainHF; 96 | //AL_REVERB_ROOM_ROLLOFF_FACTOR, 97 | double flRoomRolloffFactor; 98 | //AL_REVERB_DECAY_HFLIMIT, 99 | //int iDecayHFLimit; 100 | }; 101 | 102 | struct StandardReverbZoneSaveData 103 | { 104 | //name 105 | std::string name; 106 | 107 | //position 108 | double x; 109 | double y; 110 | double z; 111 | 112 | //size 113 | double width; 114 | 115 | //properties 116 | ReverbStandardProperties properties; 117 | }; 118 | 119 | class ReverbZone : public EffectZone 120 | { 121 | public: 122 | ReverbZone(); 123 | ~ReverbZone(); 124 | 125 | //type of reverb to use for zone 126 | enum class Type: std::int8_t {NONE=0, STANDARD, EAX}; 127 | 128 | void SetType(ReverbZone::Type& type); 129 | ReverbZone::Type& GetType(); 130 | 131 | //functions to initialize reverb zones based on type 132 | 133 | void InitStandardReverbZone(std::string& thisName, 134 | double& x, double& y, double& z, double& width, 135 | ReverbStandardProperties& properties); 136 | 137 | void InitStandardReverbZoneWithGraphicalObject(std::string& thisName, 138 | double& x, double& y, double& z, double& width, 139 | ReverbStandardProperties& properties); 140 | 141 | void InitEAXReverbZone(std::string& thisName, 142 | double& x, double& y, double& z, double& width, 143 | ReverbEAXProperties& properties); 144 | 145 | void InitEAXReverbZoneWithGraphicalObject(std::string& thisName, 146 | double& x, double& y, double& z, double& width, 147 | ReverbEAXProperties& properties); 148 | 149 | 150 | //function to change reverb properties 151 | void ChangeStandardReverbZoneProperties(ReverbStandardProperties& properties); 152 | void ChangeEAXReverbZoneProperties(ReverbEAXProperties& properties); 153 | 154 | ReverbStandardProperties& GetStandardReverbZoneProperties(); 155 | ReverbEAXProperties& GetEAXReverbZoneProperties(); 156 | 157 | 158 | virtual ALuint* GetEffectPointer(); 159 | virtual ALuint* GetEffectsSlotPointer(); 160 | 161 | virtual ALuint GetEffect(); 162 | virtual ALuint GetEffectsSlot(); 163 | 164 | virtual void FreeEffects(); 165 | 166 | StandardReverbZoneSaveData GetStandardReverbZoneSaveData(); 167 | void LoadStandardReverbZoneSaveData(StandardReverbZoneSaveData& data); 168 | 169 | EAXReverbZoneSaveData GetEAXReverbZoneSaveData(); 170 | void LoadEAXReverbZoneSaveData(EAXReverbZoneSaveData& data); 171 | 172 | //changed from effect zone to implement save data 173 | void SetPositionX(double& x); 174 | void SetPositionY(double& y); 175 | void SetPositionZ(double& z); 176 | void ChangeWidth(double width); 177 | 178 | private: 179 | 180 | ALuint m_effect; 181 | ALuint m_slot; 182 | 183 | //type of reverb zone 184 | ReverbZone::Type m_type; 185 | 186 | ALuint LoadStandardReverbEffect(const EFXEAXREVERBPROPERTIES *reverb); 187 | ALuint LoadEAXReverbEffect(const EFXEAXREVERBPROPERTIES *reverb); 188 | 189 | ReverbStandardProperties m_standard_prop; 190 | ReverbEAXProperties m_eax_prop; 191 | 192 | ZoneColor standardColor; 193 | ZoneColor eaxColor; 194 | 195 | StandardReverbZoneSaveData m_saveDataStandard; 196 | EAXReverbZoneSaveData m_saveDataEAX; 197 | }; 198 | 199 | #endif 200 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # binaural-audio-editor 3 | This is an audio application that produces binaural audio from 2D mono audio samples and positional information given through the graphical user interface. Listen to 3D audio through stereo headphones. 4 | 5 | ## Moving on to a new project that will replace this one. 3d Audio Producer. 6 | ## https://github.com/adct-the-experimenter/3d-audio-producer 7 | ## Keeping this here active on Github for anyone who wants to fork this. 8 | 9 | Resize the window if unable to move timeline. 10 | 11 | [![Open Source Helpers](https://www.codetriage.com/adct-the-experimenter/binaural-audio-editor/badges/users.svg)](https://www.codetriage.com/adct-the-experimenter/binaural-audio-editor) 12 | 13 | ## Required Libraries 14 | - OpenAL Soft https://github.com/kcat/openal-soft 15 | 16 | - openscenegraph https://github.com/openscenegraph/OpenSceneGraph 17 | 18 | - libsndfile http://www.mega-nerd.com/libsndfile/ 19 | 20 | - wxwidgets https://www.wxwidgets.org/ 21 | 22 | - Boost Math Quaternion headers and Boost ASIO serial https://www.boost.org/users/history/version_1_70_0.html 23 | 24 | - PugiXML https://github.com/zeux/pugixml/ 25 | 26 | ## How to Install 27 | 28 | 1. Install required libraries. 29 | 2. Clone this repository 30 | 3. cd binaural-audio-editor 31 | 4. mkdir build 32 | 5. cd build 33 | 6. cmake .. -DwxWidgets_CONFIG_EXECUTABLE=path-to-wxconfig-executable 34 | 35 | FreeBSD: path-to-wxconfig-executable = /usr/local/bin/wxgtk3u-3.1-config 36 | 37 | Linux: path-to-wxconfig-executable = /usr/bin/wx-config-gtk3 38 | 7. make 39 | 8. ./binaural-audio-editor 40 | 41 | ## Controls 42 | 43 | - Left Click and mouse movement to move orientation of the camera i.e. the direction the camera is facing. 44 | 45 | - Right Click and mouse movement to move the camera forward or backward. 46 | 47 | - Left Click + Right Click and mouse movement to move the camera up, down, left, or right. 48 | 49 | ## Instructions 50 | 51 | ### Control Listener 52 | 53 | Light green cube is you the listener. 54 | 55 | Use WASD keys to move listener(you) forward, back, left, right. Q key moves listener down. E key moves listener up. 56 | 57 | To use the Listener Track(Group of first 7 tracks with graph) to change position of the listener(you), uncheck Free Roam in EditListener menu. 58 | Add points to the graph by left clicking on the graph. Remove points from the graph by right clicking. 59 | 60 | 61 | First graph controls the x position, second graph is for y position, third graph is for z position. 62 | 63 | 64 | Fourth graph controls w parameter of quaternion rotation, fifth graph controls rotation around x axis, sixth graph controls rotation around y axis, seventh graph controls rotation around z axis. 65 | 66 | To use IMU BNO055 sensor to control listener orientation. 67 | See file External-Orientation-Setup.md 68 | 69 | ### Control SoundProducers 70 | 71 | Light blue cubes are the sound producers. 72 | 73 | Create a sound producer and name it in Sound Producers -> Create Sound Producers menu. 74 | 75 | For the Sound Producer track, the top 2 tracks is for graphing audio and the bottom 3 tracks are for changing position of the sound producer. 76 | 77 | Click on dropdown box menu of sound producer track to choose a soundproducer to edit that was created. 78 | 79 | Click on browse button near audio track to load sound into the track. Load only 8-bit or 16-bit audio only. 80 | 81 | To move a sound producer with keyboard keys, set the free roam option as true when creating it or editing it. 82 | This option allows the sound producer to keep its position set by keys during playback. 83 | The select the sound producer in the drop-down menu in the tool bar and use I,J,K,L,U,O keys to move it. 84 | 85 | ### Coordinate System of Binaural Audio Editor and OpenAL Soft 86 | Like OpenAL, the application uses a right handed coordinate system to move listener and sound producers, where in a frontal default view X (thumb) points right, Y points up (index finger), and Z points towards the viewer/camera (middle finger). 87 | 88 | - Up is positive y. Down is negative y. 89 | 90 | - Back is positive z. Forward is negative z. 91 | 92 | - Right is positive x. Left is negative x. 93 | 94 | ## Important Note About Multi-channel Audio Input: 95 | Stereo(2 channel) audio does not get 3d spatialization and is instead used to play as background music. 96 | 97 | Have audio that you want to be played in 3D be mono(1 channel) audio 98 | and load it into the audio track. 99 | 100 | Stereo audio can be changed to mono audio using Audacity or other programs. 101 | 102 | sndfile-mix-to-mono is an application that successfully turns multi-channel audio mix into mono-channel audio mix. 103 | 104 | 105 | ## Experimental Feature for 5.1,6.1,7.1 channel Surround Sound Output 106 | Run the alsoft-config program that came with the installation of OpenAL Soft to 107 | set the output to 5.1, 6.1, or 7.1 channels. 108 | OpenAL Soft should automatically convert 3d audio information into audio output for surround sound. 109 | 110 | For more information, read https://github.com/kcat/openal-soft/blob/master/docs/3D7.1.txt 111 | 112 | ## To use with Digital Audio Workstation 113 | 114 | See the import-audio-DAW-BAE plugin page about building and installing the plugin. 115 | 116 | https://github.com/adct-the-experimenter/import-audio-DAW-BAE 117 | 118 | This plugin will export audio from a digital audio workstation to the sound tracks of binaural audio editor so that one can use their DAW to edit audio and spatialize it in Binaural Audio Editor. 119 | 120 | ## Shortcut Keys 121 | 122 | Press b with focus on graphical screen with 3d cubes to attach the last sound producer created to the last sound producer track and browse audio for it. 123 | 124 | 125 | ## Feedback 126 | 127 | Please email questions or comments to this email address bringerofawesomefood @ gmail . com without spaces. 128 | -------------------------------------------------------------------------------- /src/timeline-track-editor/src/timeline-window.cpp: -------------------------------------------------------------------------------- 1 | #include "timeline-window.h" 2 | 3 | TimelineWindow::TimelineWindow(wxWindow *parent) : wxScrolled(parent, wxID_ANY) 4 | { 5 | m_parent = parent; 6 | 7 | current_time_pos = 0; 8 | 9 | SetScrollRate( 10, 10 ); //how many pixels to increment when scrolling 10 | SetVirtualSize( TRACK_WIDTH, TRACK_HEIGHT ); //actual size of what will be scrolled 11 | SetBackgroundColour( *wxWHITE ); 12 | 13 | 14 | Connect(ID_SLIDER, wxEVT_COMMAND_SLIDER_UPDATED, wxScrollEventHandler(TimelineWindow::OnScroll)); 15 | Connect(wxEVT_PAINT, wxPaintEventHandler(TimelineWindow::OnPaint)); 16 | Connect(wxEVT_SIZE, wxSizeEventHandler(TimelineWindow::OnSize)); 17 | 18 | TimelineWindow::InitTimeline(); 19 | 20 | main_v_box = new wxBoxSizer(wxVERTICAL); 21 | 22 | //make horizontal box to put names in 23 | wxBoxSizer *hboxSlider = new wxBoxSizer(wxHORIZONTAL); 24 | 25 | //add slider to box 26 | //keep slider at slider start position 27 | hboxSlider->Add(m_slider, 0, wxLEFT | wxRIGHT | wxEXPAND, slider_start_x_pos); 28 | 29 | //add horizontal box containing slider 30 | //keep horizontal box containing slider 20 pixels from the top to keep ruler visible 31 | main_v_box->Add(hboxSlider, 0, wxTOP | wxALIGN_TOP, 20); 32 | 33 | SetSizerAndFit(main_v_box); 34 | Center(); 35 | } 36 | 37 | void TimelineWindow::InitTimeline() 38 | { 39 | m_slider_value = 0; 40 | 41 | //intialize m_time_num 42 | TimelineWindow::InitTimeVector(); 43 | 44 | slider_start_x_pos = TRACK_WIDTH / (TIME_TICK_NUM - 1); 45 | 46 | m_slider = new wxSlider(this, ID_SLIDER, 0, 0, TRACK_WIDTH, wxPoint(slider_start_x_pos, 30), wxSize(TRACK_WIDTH, -1), wxSL_HORIZONTAL); 47 | 48 | } 49 | 50 | void TimelineWindow::InitTimeVector() 51 | { 52 | //get linearly spaced vector of doubles 53 | std::vector thisVector = TimelineWindow::LinearSpacedArray(TIME_START_VALUE,TIME_END_VALUE,TIME_TICK_NUM); 54 | 55 | for(size_t i=0; i < thisVector.size(); ++i) 56 | { 57 | m_time_num.push_back((int)thisVector[i]); 58 | } 59 | } 60 | 61 | std::vector TimelineWindow::LinearSpacedArray(double a, double b, std::size_t N) 62 | { 63 | // Linear interpolation following MATLAB linspace 64 | double h = (b - a) / static_cast(N-1); 65 | std::vector xs(N); 66 | std::vector::iterator x; 67 | double val; 68 | for (x = xs.begin(), val = a; x != xs.end(); ++x, val += h) { 69 | *x = val; 70 | } 71 | return xs; 72 | } 73 | 74 | std::vector * TimelineWindow::GetTimeTickVector(){return &m_time_num;} 75 | 76 | void TimelineWindow::OnScroll(wxScrollEvent& event) 77 | { 78 | m_slider_value = m_slider->GetValue(); 79 | 80 | current_time_pos = m_slider_value * ((double)TIME_END_VALUE / (double)TRACK_WIDTH); 81 | 82 | Refresh(); //for wxDc onPaint stuff 83 | 84 | FitInside(); //for scroll and sizer 85 | } 86 | 87 | void TimelineWindow::OnSize(wxSizeEvent& event) 88 | { 89 | Refresh(); //for wxDc onPaint stuff 90 | 91 | FitInside(); //for resize and sizer 92 | } 93 | 94 | void TimelineWindow::OnPaint(wxPaintEvent& event) 95 | { 96 | wxPaintDC dc(this); 97 | 98 | DoPrepareDC(dc); //prepare device context for drawing a scrolling image 99 | 100 | //Initialize variables for drawing vertical timeline line indicating current position 101 | wxPen pen(wxColour(0, 0, 0)); //make pen color very black 102 | dc.SetPen(pen); 103 | 104 | wxBrush brush1(wxColour(197, 108, 0)); 105 | dc.SetBrush(brush1); 106 | 107 | 108 | //x coordinate of vertical line representing current position in time 109 | wxCoord x = m_slider_value + slider_start_x_pos; 110 | 111 | dc.DrawRectangle( wxRect(x, 0, 2, VERTICAL_LINE_HEIGHT_TIME) ); 112 | 113 | 114 | //initialize variables for timeline ruler 115 | 116 | wxFont font = wxSystemSettings::GetFont(wxSYS_SYSTEM_FONT); 117 | dc.SetFont(font); 118 | 119 | int step = (int) round( TRACK_WIDTH / (TIME_TICK_NUM-1) ); 120 | 121 | dc.SetPen(wxPen(wxColour(90, 80, 60))); 122 | 123 | for ( int i=1; i <= (int)m_time_num.size(); i++ ) 124 | { 125 | dc.DrawLine(i*step, 1, i*step, 10); 126 | dc.DrawText( wxString::Format( wxT("%ds"), m_time_num[i-1] ) , i*step, 10); 127 | } 128 | } 129 | 130 | void TimelineWindow::SetCurrentTimePosition(double& thisTime) 131 | { 132 | Refresh(); //for updating paint drawing everytime current time position set 133 | 134 | current_time_pos = thisTime; 135 | 136 | //set slider to current time position 137 | int graphical_value = thisTime * (TRACK_WIDTH / TIME_END_VALUE); 138 | m_slider->SetValue(graphical_value); 139 | m_slider_value = graphical_value; 140 | } 141 | 142 | double TimelineWindow::GetCurrentTimePosition(){return current_time_pos;} 143 | 144 | void TimelineWindow::AddTrack(Track* thisTrack, int& space) 145 | { 146 | //initialize track 147 | thisTrack->InitTrack(this,&m_time_num); 148 | thisTrack->SetReferenceToCurrentTimeVariable(¤t_time_pos); 149 | 150 | //make horizontal box to put track in 151 | wxBoxSizer *hboxTrack = new wxBoxSizer(wxHORIZONTAL); 152 | 153 | //put track in horizontal box 154 | hboxTrack->Add(thisTrack, 0, wxRIGHT | wxLEFT, slider_start_x_pos); 155 | 156 | //add track to timeline window 157 | main_v_box->Add(hboxTrack, 1, wxTOP | wxALIGN_TOP,space); 158 | 159 | SetSizerAndFit(main_v_box); 160 | } 161 | 162 | void TimelineWindow::AddSpacerBlock(int space) 163 | { 164 | main_v_box->AddSpacer(space); 165 | SetSizerAndFit(main_v_box); 166 | } 167 | 168 | void TimelineWindow::AddBoxSizer(wxSizer *sizer,int proportion,int flag,int border,wxObject *userData) 169 | { 170 | // flags = OR-combination of flags affecting sizer's behaviour. See wxSizer flags list for details. 171 | main_v_box->Add(sizer,proportion,flag,border,userData); 172 | 173 | SetSizerAndFit(main_v_box); 174 | } 175 | 176 | void TimelineWindow::AddText(wxString thisText, wxPoint thisPoint) 177 | { 178 | wxStaticText *st1 = new wxStaticText(this, wxID_ANY, thisText,thisPoint ); 179 | } 180 | 181 | wxSlider* TimelineWindow::getSliderReference(){return m_slider;} 182 | double* TimelineWindow::getPointerToCurrentTimeReference(){return ¤t_time_pos;} 183 | -------------------------------------------------------------------------------- /src/soundproducer.cpp: -------------------------------------------------------------------------------- 1 | // For compilers that support precompilation, includes "wx.h". 2 | #include "wx/wxprec.h" 3 | 4 | #ifdef __BORLANDC__ 5 | #pragma hdrstop 6 | #endif 7 | 8 | #ifdef WIN32 9 | #include 10 | #endif 11 | 12 | #ifndef WX_PRECOMP 13 | #include "wx/wx.h" 14 | #endif 15 | 16 | #include "soundproducer.h" 17 | 18 | SoundProducer::SoundProducer() 19 | { 20 | 21 | //initialize buffer as empty 22 | m_buffer = 0; 23 | 24 | //initialize position vector 25 | producer_position_vector.resize(3); 26 | producer_position_vector[POSITION_INDEX::X] = 0; 27 | producer_position_vector[POSITION_INDEX::Y] = 0; 28 | producer_position_vector[POSITION_INDEX::Z] = 0; 29 | 30 | track_source_ptr = nullptr; 31 | 32 | freeRoam = false; 33 | } 34 | 35 | SoundProducer::~SoundProducer() 36 | { 37 | std::cout << "Sound Producer destructor called! \n"; 38 | if(m_source != 0) 39 | { 40 | alDeleteSources(1, &m_source); 41 | } 42 | 43 | if(m_buffer != 0) 44 | { 45 | alDeleteBuffers(1, &m_buffer); 46 | } 47 | } 48 | 49 | void SoundProducer::InitSoundProducer(std::string& thisName,std::string& filepath, ALuint& buffer, 50 | double& x, double& y, double& z) 51 | { 52 | //intialize source 53 | SoundProducer::CreateSource(); 54 | 55 | name = thisName; 56 | m_filepath = filepath; 57 | 58 | if(buffer != 0) 59 | { 60 | SoundProducer::setBuffer(buffer); 61 | } 62 | 63 | //set position 64 | producer_position_vector[POSITION_INDEX::X] = x; 65 | producer_position_vector[POSITION_INDEX::Y] = y; 66 | producer_position_vector[POSITION_INDEX::Z] = z; 67 | 68 | //make box 69 | //create ShapeDrawable object 70 | m_renderObject = new osg::ShapeDrawable; 71 | m_box = new osg::Box(osg::Vec3(0.0f, 0.0f, 0.0f),1.0f); 72 | 73 | //make ShapeDrawable object a box 74 | //initialize box at certain position 75 | m_renderObject->setShape(m_box); 76 | //set color of ShapeDrawable object with box 77 | m_renderObject->setColor( osg::Vec4(0.0f, 1.0f, 1.0f, 1.0f) ); 78 | 79 | m_geode = new osg::Geode; 80 | m_geode->addDrawable( m_renderObject.get() ); 81 | 82 | 83 | // Create transformation node 84 | m_paTransform = new osg::PositionAttitudeTransform; 85 | 86 | //initialize transform and add geode to it 87 | m_paTransform->setPosition( osg::Vec3(x,y,z)); 88 | m_paTransform->addChild(m_geode); 89 | 90 | moveSource(); 91 | 92 | //init save data 93 | m_saveData.name = thisName; 94 | m_saveData.x = x; 95 | m_saveData.y = y; 96 | m_saveData.z = z; 97 | } 98 | 99 | void SoundProducer::SetNameString(std::string& thisName){ name = thisName;} 100 | std::string SoundProducer::GetNameString(){ return name;} 101 | 102 | void SoundProducer::moveSource() 103 | { 104 | //if source is defined 105 | if(m_source != 0) 106 | { 107 | 108 | //move source 109 | alSource3f(m_source, AL_POSITION, 110 | (ALfloat)producer_position_vector[POSITION_INDEX::X], 111 | (ALfloat)producer_position_vector[POSITION_INDEX::Y], 112 | (ALfloat)producer_position_vector[POSITION_INDEX::Z]); 113 | } 114 | 115 | if(track_source_ptr != nullptr) 116 | { 117 | //move source 118 | alSource3f(*track_source_ptr, AL_POSITION, 119 | (ALfloat)producer_position_vector[POSITION_INDEX::X], 120 | (ALfloat)producer_position_vector[POSITION_INDEX::Y], 121 | (ALfloat)producer_position_vector[POSITION_INDEX::Z]); 122 | } 123 | } 124 | 125 | void SoundProducer::SetPositionX(double& x) 126 | { 127 | producer_position_vector[POSITION_INDEX::X] = x; 128 | 129 | m_paTransform->setPosition(osg::Vec3(x, 130 | producer_position_vector[POSITION_INDEX::Y], 131 | producer_position_vector[POSITION_INDEX::Z])); 132 | moveSource(); 133 | 134 | m_saveData.x = x; 135 | } 136 | 137 | double SoundProducer::GetPositionX(){return producer_position_vector[POSITION_INDEX::X];} 138 | 139 | void SoundProducer::SetPositionY(double& y) 140 | { 141 | producer_position_vector[POSITION_INDEX::Y] = y; 142 | 143 | m_paTransform->setPosition(osg::Vec3(producer_position_vector[POSITION_INDEX::X], 144 | y, 145 | producer_position_vector[POSITION_INDEX::Z])); 146 | moveSource(); 147 | 148 | m_saveData.y = y; 149 | } 150 | 151 | double SoundProducer::GetPositionY(){return producer_position_vector[POSITION_INDEX::Y];} 152 | 153 | void SoundProducer::SetPositionZ(double& z) 154 | { 155 | producer_position_vector[POSITION_INDEX::Z] = z; 156 | 157 | m_paTransform->setPosition(osg::Vec3(producer_position_vector[POSITION_INDEX::X], 158 | producer_position_vector[POSITION_INDEX::Y], 159 | z)); 160 | moveSource(); 161 | 162 | m_saveData.z = z; 163 | } 164 | 165 | double SoundProducer::GetPositionZ(){return producer_position_vector[POSITION_INDEX::Z];} 166 | 167 | void SoundProducer::setFilepathToSound(std::string& filepath){m_filepath = filepath;} 168 | 169 | std::string& SoundProducer::getFilepathToSound(){return m_filepath;} 170 | 171 | void SoundProducer::setBuffer(ALuint& thisBuffer) 172 | { 173 | m_buffer = thisBuffer; 174 | 175 | //attach new buffer to source if source is defined 176 | if(m_source != 0) 177 | { 178 | alSourcei(m_source, AL_SOURCE_RELATIVE, AL_TRUE); 179 | alSourcei(m_source, AL_BUFFER, m_buffer); 180 | } 181 | } 182 | ALuint* SoundProducer::getBuffer(){return &m_buffer;} 183 | 184 | void SoundProducer::CreateSource() 185 | { 186 | alGenSources(1, &m_source); 187 | alSourcei(m_source, AL_SOURCE_RELATIVE, AL_FALSE); 188 | assert(alGetError()==AL_NO_ERROR && "Failed to setup sound source."); 189 | } 190 | 191 | void SoundProducer::setSource(ALuint& thisSource){m_source = thisSource;} 192 | ALuint* SoundProducer::getSource(){return &m_source;} 193 | 194 | osg::ShapeDrawable* SoundProducer::getRenderObject(){return m_renderObject;} 195 | 196 | osg::Geode* SoundProducer::getGeodeNode(){return m_geode;} 197 | 198 | osg::PositionAttitudeTransform* SoundProducer::getTransformNode(){return m_paTransform;} 199 | 200 | void SoundProducer::SetReferenceToTrackSource(ALuint* thisSource){track_source_ptr = thisSource;} 201 | 202 | SoundProducerSaveData SoundProducer::GetSoundProducerSaveData(){return m_saveData;} 203 | 204 | void SoundProducer::LoadSoundProducerSaveData(SoundProducerSaveData& data) 205 | { 206 | m_saveData = data; 207 | 208 | } 209 | 210 | void SoundProducer::SetFreeRoamBool(bool state){freeRoam = state;} 211 | 212 | bool SoundProducer::GetFreeRoamBool(){return freeRoam;} 213 | -------------------------------------------------------------------------------- /src/timeline-track-editor/src/double-track.cpp: -------------------------------------------------------------------------------- 1 | #include "double-track.h" 2 | 3 | DoubleTrack::DoubleTrack(const wxString& title) : Track (title) 4 | { 5 | varToManipulatePtr = nullptr; 6 | graphEditor = nullptr; 7 | 8 | playbackControlsPtr = nullptr; 9 | 10 | Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(DoubleTrack::OnLeftMouseClick)); 11 | Connect(wxEVT_CONTEXT_MENU, wxCommandEventHandler(DoubleTrack::OnRightMouseClick)); 12 | 13 | } 14 | 15 | void DoubleTrack::FunctionToCallInPlayState() 16 | { 17 | if(varToManipulatePtr != nullptr) 18 | { 19 | //change variable 20 | if(graphEditor != nullptr) 21 | { 22 | double thisTime = DoubleTrack::GetCurrentTime(); 23 | 24 | 25 | //check if there is a point at that time value 26 | if ( map_time_output.find(thisTime) == map_time_output.end() ) 27 | { 28 | //if not found, do nothing 29 | } 30 | else 31 | { 32 | //if found 33 | 34 | //get iterator to vector from time map 35 | std::unordered_map::const_iterator got = map_time_output.find (thisTime); 36 | 37 | //std::cout << "value " << got->second << " found at time " << got->first << std::endl; 38 | if(*varToManipulatePtr != got->second) 39 | { 40 | *varToManipulatePtr = got->second; 41 | 42 | //call this void function after variable change 43 | //if it has a callable function target 44 | if(func_after_var_change) 45 | { 46 | func_after_var_change(); 47 | } 48 | } 49 | } 50 | } 51 | } 52 | } 53 | 54 | void DoubleTrack::FunctionToCallInPauseState(){} 55 | 56 | void DoubleTrack::FunctionToCallInRewindState(){} 57 | 58 | void DoubleTrack::FunctionToCallInFastForwardState(){} 59 | 60 | void DoubleTrack::FunctionToCallInNullState(){} 61 | 62 | void DoubleTrack::SetReferenceToCurrentTimeVariable(double* thisTimeVariable){Track::SetReferenceToCurrentTimeVariable(thisTimeVariable);} 63 | 64 | std::vector * DoubleTrack::GetReferenceToTimeTickVector(){return Track::GetReferenceToTimeTickVector();} 65 | 66 | void DoubleTrack::SetReferenceToTimeTickVector(std::vector *thisVector){Track::SetReferenceToTimeTickVector(thisVector);} 67 | 68 | void DoubleTrack::SetReferenceToVarToManipulate(double* thisVar){varToManipulatePtr = thisVar;} 69 | 70 | double DoubleTrack::GetCurrentTime(){return Track::GetCurrentTime();} 71 | 72 | void DoubleTrack::SetTitle(wxString thisTitle){Track::SetTitle(thisTitle);} 73 | wxString DoubleTrack::GetTitle(){return Track::GetTitle();} 74 | 75 | void DoubleTrack::InitTrack(wxWindow* parent, std::vector *timeTickVector) 76 | { 77 | Track::InitTrack(parent,timeTickVector); 78 | 79 | //initialize graph editor 80 | graphEditor = new EditorGraph(this); 81 | graphEditor->SetReferenceToTimeTickVector(timeTickVector); 82 | 83 | //wxStaticText *st1 = new wxStaticText(parent, wxID_ANY, DoubleTrack::GetTitle(), 84 | // wxPoint(this->GetScreenPosition().x,this->GetScreenPosition().y) ); 85 | } 86 | 87 | void DoubleTrack::SetupAxisForVariable(double& start, double& end,double& resolution, int& numTick) 88 | { 89 | verticalStart = start; 90 | verticalEnd = end; 91 | verticalNumTicks = numTick; 92 | verticalResolution = resolution; 93 | 94 | //setup tick marks 95 | DoubleTrack::InitVerticalAxis(); 96 | } 97 | 98 | void DoubleTrack::InitVerticalAxis() 99 | { 100 | //get linearly spaced vector of doubles 101 | std::vector thisVector = DoubleTrack::LinearSpacedArray(verticalStart,verticalEnd,(size_t)verticalNumTicks); 102 | 103 | for(size_t i=0; i < thisVector.size(); ++i) 104 | { 105 | m_vertical_var_num.push_back(thisVector[i]); 106 | } 107 | } 108 | 109 | std::vector DoubleTrack::LinearSpacedArray(double a, double b, std::size_t N) 110 | { 111 | // Linear interpolation following MATLAB linspace 112 | double h = (b - a) / static_cast(N-1); 113 | std::vector xs(N); 114 | std::vector::iterator x; 115 | double val; 116 | for (x = xs.begin(), val = a; x != xs.end(); ++x, val += h) { 117 | *x = val; 118 | } 119 | return xs; 120 | } 121 | 122 | void DoubleTrack::OnSize(wxSizeEvent& event) 123 | { 124 | Refresh(); 125 | 126 | FitInside(); 127 | } 128 | 129 | void DoubleTrack::OnScroll(wxScrollEvent& event) 130 | { 131 | //std::cout << "Scroll called! \n"; 132 | Refresh(); //for wxDc onPaint stuff 133 | 134 | FitInside(); //for scroll and sizer 135 | } 136 | 137 | 138 | void DoubleTrack::OnPaint(wxPaintEvent& event) 139 | { 140 | wxPaintDC dc(this); 141 | 142 | DoubleTrack::render(dc); 143 | 144 | event.Skip(); 145 | } 146 | 147 | void DoubleTrack::render(wxDC& dc) 148 | { 149 | PrepareDC(dc); //prepare device context for drawing a scrolling image 150 | 151 | graphEditor->render(dc,&m_vertical_var_num); 152 | } 153 | 154 | void DoubleTrack::OnLeftMouseClick(wxMouseEvent& event) 155 | { 156 | DoubleTrack::logic_left_click(); 157 | event.Skip(); 158 | } 159 | 160 | void DoubleTrack::OnRightMouseClick(wxCommandEvent& event) 161 | { 162 | DoubleTrack::logic_right_click(); 163 | event.Skip(); 164 | } 165 | 166 | void DoubleTrack::logic_left_click() 167 | { 168 | double mouseTimePoint; 169 | int mouseYPoint; 170 | bool legitValues = true; 171 | 172 | graphEditor->mouseDownLeftClick(verticalStart,verticalEnd,verticalResolution, 173 | mouseTimePoint, mouseYPoint,legitValues); 174 | 175 | if(legitValues) 176 | { 177 | //convert mouse y point to output value 178 | double output = ((double)TRACK_HEIGHT - mouseYPoint) * ((verticalEnd - verticalStart) / double(TRACK_HEIGHT) ) - verticalEnd; 179 | 180 | //put it in the map 181 | map_time_output.emplace(mouseTimePoint, output); 182 | 183 | Refresh(); 184 | } 185 | 186 | 187 | 188 | } 189 | 190 | void DoubleTrack::logic_right_click() 191 | { 192 | double mouseTimePoint; 193 | bool legitValue = true; 194 | 195 | graphEditor->mouseDownRightClick(mouseTimePoint, legitValue); 196 | 197 | if(legitValue) 198 | { 199 | //remove point from the map 200 | map_time_output.erase(mouseTimePoint); 201 | 202 | Refresh(); 203 | } 204 | 205 | 206 | } 207 | 208 | void DoubleTrack::SetFunctionToCallAfterVariableChange(std::function < void() > thisFunction){func_after_var_change = thisFunction;} 209 | 210 | void DoubleTrack::SetReferenceToPlaybackControls(PlaybackControls* controls){playbackControlsPtr = controls;} 211 | PlaybackControls* DoubleTrack::GetReferenceToPlaybackControls(){return playbackControlsPtr;} 212 | 213 | DDMap* DoubleTrack::GetPointerToTimeValueMap(){return &map_time_output;} 214 | 215 | void DoubleTrack::LoadDataFromThisTimeValueMap(DDMap& map) 216 | { 217 | map_time_output = map; 218 | 219 | graphEditor->PlacePointsFromThisMap(map_time_output,verticalStart,verticalEnd,verticalResolution); 220 | } 221 | -------------------------------------------------------------------------------- /src/timeline-track-editor/src/playback-controls.cpp: -------------------------------------------------------------------------------- 1 | #include "playback-controls.h" 2 | 3 | 4 | PlaybackControls::PlaybackControls(wxWindow* parent) : wxWindow(parent, wxID_ANY) 5 | { 6 | time_res_seconds = double(TIME_RESOLUTION) / 1000; 7 | time_rewind_seconds = time_res_seconds * double(REWIND_SPEED); 8 | time_fast_forward_seconds = time_res_seconds * double(FAST_FORWARD_SPEED); 9 | 10 | //make horizontal box to put buttons in 11 | wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL); 12 | 13 | //initialize buttons 14 | m_play_button = new wxButton(this, wxID_NEW, wxT("Play"));; 15 | m_pause_button = new wxButton(this, wxID_NEW, wxT("Pause"));; 16 | m_stop_button = new wxButton(this, wxID_NEW, wxT("Stop"));; 17 | m_rewind_button = new wxButton(this, wxID_NEW, wxT("Rewind"));; 18 | m_fast_forward_button = new wxButton(this, wxID_NEW, wxT("Fast Forward"));; 19 | 20 | m_play_button->Bind(wxEVT_BUTTON,&PlaybackControls::Play,this); 21 | m_pause_button->Bind(wxEVT_BUTTON,&PlaybackControls::Pause,this); 22 | m_stop_button->Bind(wxEVT_BUTTON,&PlaybackControls::Stop,this); 23 | m_rewind_button->Bind(wxEVT_BUTTON,&PlaybackControls::Rewind,this); 24 | m_fast_forward_button->Bind(wxEVT_BUTTON,&PlaybackControls::FastForward,this); 25 | 26 | hbox->Add(m_play_button, 0, wxALL, 0); 27 | hbox->Add(m_pause_button, 0, wxALL, 0); 28 | hbox->Add(m_stop_button, 0, wxALL, 0); 29 | hbox->Add(m_rewind_button, 0, wxALL, 0); 30 | hbox->Add(m_fast_forward_button, 0, wxALL, 0); 31 | 32 | SetSizerAndFit(hbox); 33 | 34 | timelineWindowPtr = nullptr; 35 | } 36 | 37 | void PlaybackControls::RunPlaybackState() 38 | { 39 | switch (current_state) 40 | { 41 | case STATE_NULL:{ break;} 42 | case STATE_PLAY: 43 | { 44 | PlaybackControls::PlayOP(); 45 | break; 46 | } 47 | case STATE_PAUSE: 48 | { 49 | PlaybackControls::PauseOP(); 50 | 51 | break; 52 | } 53 | case STATE_REWIND: 54 | { 55 | PlaybackControls::RewindOP(); 56 | break; 57 | 58 | } 59 | case STATE_FAST_FORWARD: 60 | { 61 | PlaybackControls::FastForwardOP(); 62 | break; 63 | } 64 | }; 65 | } 66 | 67 | 68 | 69 | void PlaybackControls::Play(wxCommandEvent& event) 70 | { 71 | current_state = STATE_PLAY; 72 | } 73 | 74 | void PlaybackControls::Pause(wxCommandEvent& event) 75 | { 76 | current_state = STATE_PAUSE; 77 | } 78 | 79 | void PlaybackControls::Stop(wxCommandEvent& event) 80 | { 81 | PlaybackControls::StopOP(); 82 | } 83 | 84 | void PlaybackControls::Rewind(wxCommandEvent& event) 85 | { 86 | current_state = STATE_REWIND; 87 | } 88 | 89 | void PlaybackControls::FastForward(wxCommandEvent& event) 90 | { 91 | current_state = STATE_FAST_FORWARD; 92 | } 93 | 94 | void PlaybackControls::SetReferenceToTimelineWindow(TimelineWindow* thisTimeline){timelineWindowPtr = thisTimeline;} 95 | 96 | void PlaybackControls::SetCurrentState(int state){current_state = state;} 97 | int PlaybackControls::GetCurrentState(){return current_state;} 98 | 99 | void PlaybackControls::SetCurrentTimePosition(double& thisTime) 100 | { 101 | if(timelineWindowPtr != nullptr) 102 | { 103 | timelineWindowPtr->SetCurrentTimePosition(thisTime); 104 | } 105 | } 106 | 107 | void PlaybackControls::PlayOP() 108 | { 109 | if(timelineWindowPtr != nullptr) 110 | { 111 | //if current time is past the end 112 | if(timelineWindowPtr->GetCurrentTimePosition() <= TIME_END_VALUE) 113 | { 114 | //increment current time position until end, then set state to null 115 | double newTime = timelineWindowPtr->GetCurrentTimePosition() + time_res_seconds; 116 | timelineWindowPtr->SetCurrentTimePosition(newTime); 117 | } 118 | else 119 | { 120 | //set current time to end and put it in null state 121 | double newTime = TIME_END_VALUE; 122 | timelineWindowPtr->SetCurrentTimePosition(newTime); 123 | current_state = STATE_NULL; 124 | } 125 | } 126 | } 127 | 128 | void PlaybackControls::PauseOP() 129 | { 130 | if(timelineWindowPtr != nullptr) 131 | { 132 | //do nothing 133 | } 134 | } 135 | 136 | void PlaybackControls::StopOP() 137 | { 138 | //reset time back to start 139 | double newTime = 0.0; 140 | timelineWindowPtr->SetCurrentTimePosition(newTime); 141 | 142 | current_state = STATE_NULL; 143 | } 144 | 145 | void PlaybackControls::RewindOP() 146 | { 147 | if(timelineWindowPtr != nullptr) 148 | { 149 | if(timelineWindowPtr->GetCurrentTimePosition() >= TIME_START_VALUE) 150 | { 151 | //decrement current time position until beginning, then set state to null 152 | double newTime = timelineWindowPtr->GetCurrentTimePosition() - time_rewind_seconds; 153 | timelineWindowPtr->SetCurrentTimePosition(newTime); 154 | } 155 | else 156 | { 157 | double newTime = TIME_START_VALUE; 158 | timelineWindowPtr->SetCurrentTimePosition(newTime); 159 | current_state = STATE_NULL; 160 | } 161 | } 162 | 163 | } 164 | 165 | void PlaybackControls::FastForwardOP() 166 | { 167 | if(timelineWindowPtr != nullptr) 168 | { 169 | //if current time is past the end 170 | if(timelineWindowPtr->GetCurrentTimePosition() <= TIME_END_VALUE) 171 | { 172 | //increment current time position until end, then set state to null 173 | double newTime = timelineWindowPtr->GetCurrentTimePosition() + time_fast_forward_seconds; 174 | timelineWindowPtr->SetCurrentTimePosition(newTime); 175 | } 176 | else 177 | { 178 | //set current time to end and put it in null state 179 | double newTime = TIME_END_VALUE; 180 | timelineWindowPtr->SetCurrentTimePosition(newTime); 181 | current_state = STATE_NULL; 182 | } 183 | } 184 | } 185 | 186 | //Playback Timer 187 | 188 | PlaybackTimer::PlaybackTimer(PlaybackControls* controls) : wxTimer() 189 | { 190 | m_controls = controls; 191 | } 192 | 193 | void PlaybackTimer::Notify() 194 | { 195 | m_controls->RunPlaybackState(); 196 | 197 | switch(m_controls->GetCurrentState()) 198 | { 199 | case PlaybackControls::STATE_PLAY: 200 | { 201 | for (auto& x: functionsPlayState) {x();} 202 | break; 203 | } 204 | 205 | case PlaybackControls::STATE_PAUSE: 206 | { 207 | for (auto& x: functionsPauseState) {x();} 208 | break; 209 | } 210 | 211 | case PlaybackControls::STATE_REWIND: 212 | { 213 | for (auto& x: functionsRewindState) {x();} 214 | break; 215 | } 216 | 217 | case PlaybackControls::STATE_FAST_FORWARD: 218 | { 219 | for (auto& x: functionsFastForwardState) {x();} 220 | break; 221 | } 222 | 223 | case PlaybackControls::STATE_NULL: 224 | { 225 | for (auto& x: functionsNullState) {x();} 226 | break; 227 | } 228 | } 229 | 230 | } 231 | 232 | void PlaybackTimer::start() 233 | { 234 | wxTimer::Start(TIME_RESOLUTION,wxTIMER_CONTINUOUS); //the timer calls Notify every TIMER_INTERVAL milliseconds 235 | } 236 | 237 | void PlaybackTimer::AddFunctionToTimerLoopPlayState( std::function < void() > thisFunction) 238 | { 239 | functionsPlayState.push_back(thisFunction); 240 | } 241 | 242 | void PlaybackTimer::AddFunctionToTimerLoopPauseState( std::function < void() > thisFunction) 243 | { 244 | functionsPauseState.push_back(thisFunction); 245 | } 246 | 247 | void PlaybackTimer::AddFunctionToTimerLoopRewindState( std::function < void() > thisFunction) 248 | { 249 | functionsRewindState.push_back(thisFunction); 250 | } 251 | 252 | void PlaybackTimer::AddFunctionToTimerLoopFastForwardState( std::function < void() > thisFunction) 253 | { 254 | functionsFastForwardState.push_back(thisFunction); 255 | } 256 | 257 | void PlaybackTimer::AddFunctionToTimerLoopNullState( std::function < void() > thisFunction) 258 | { 259 | functionsNullState.push_back(thisFunction); 260 | } 261 | 262 | -------------------------------------------------------------------------------- /src/CreateSoundProducerDialog.cpp: -------------------------------------------------------------------------------- 1 | #include "CreateSoundProducerDialog.h" 2 | 3 | CreateSoundProducerDialog::CreateSoundProducerDialog(const wxString & title, OpenAlSoftAudioEngine* audioEngine) 4 | : wxDialog(NULL, -1, title, wxDefaultPosition, wxSize(250, 230)) 5 | { 6 | 7 | ptrAudioEngine = audioEngine; 8 | 9 | //initialize text fields 10 | 11 | wxFloatingPointValidator validator(2,nullptr,wxNUM_VAL_ZERO_AS_BLANK); 12 | validator.SetRange(-10.00,10.00); // set allowable range 13 | 14 | textFieldName = new wxTextCtrl(this,-1, "Name", 15 | wxPoint(95, 20), wxSize(80,20), 16 | wxTE_PROCESS_ENTER); 17 | 18 | textFieldX = new wxTextCtrl(this,-1, "0.00", 19 | wxPoint(95, 60), wxSize(80,20), 20 | wxTE_PROCESS_ENTER, 21 | validator, // associate the text box with the desired validator 22 | wxT("")); 23 | 24 | textFieldY = new wxTextCtrl(this,-1, "0.00", 25 | wxPoint(95, 80), wxSize(80,20), 26 | wxTE_PROCESS_ENTER, 27 | validator, // associate the text box with the desired validator 28 | wxT("")); 29 | 30 | textFieldZ = new wxTextCtrl(this,-1, "0.00", 31 | wxPoint(95, 100), wxSize(80,20), 32 | wxTE_PROCESS_ENTER, 33 | validator, // associate the text box with the desired validator 34 | wxT("")); 35 | 36 | //textFieldSoundFilePath = new wxTextCtrl(this,-1, "", 37 | // wxPoint(95, 140), wxSize(80,20), 38 | // wxTE_READONLY, wxDefaultValidator, 39 | // wxT("")); 40 | 41 | //initialize text to the left of fields 42 | wxStaticText* NameText = new wxStaticText(this, -1, wxT("Name :"), wxPoint(40, 20)); 43 | wxStaticText* positionText = new wxStaticText(this, -1, wxT("Position :"), wxPoint(20, 40)); 44 | wxStaticText* xPositionText = new wxStaticText(this, -1, wxT("X :"), wxPoint(40, 60)); 45 | wxStaticText* yPositionText = new wxStaticText(this, -1, wxT("Y :"), wxPoint(40, 80)); 46 | wxStaticText* zPositionText = new wxStaticText(this, -1, wxT("Z :"), wxPoint(40, 100)); 47 | //wxStaticText* SoundText = new wxStaticText(this, -1, wxT("Sound File :"), wxPoint(20, 120)); 48 | 49 | //initialize browse button 50 | //browseButton = new wxButton(this, CreateSoundProducerDialog::ID_BROWSE, wxT("Browse"), 51 | // wxPoint(110,140), wxSize(70, 30)); 52 | 53 | //initialize Ok and Cancel buttons 54 | okButton = new wxButton(this, CreateSoundProducerDialog::ID_OK, wxT("Ok"), 55 | wxDefaultPosition, wxSize(70, 30)); 56 | 57 | cancelButton = new wxButton(this, CreateSoundProducerDialog::ID_CANCEL, wxT("Cancel"), 58 | wxDefaultPosition, wxSize(70, 30)); 59 | 60 | //add checkmark box to determine if sound producer can roam freely in world or is controlled by sound producer track 61 | checkBoxFreeRoam = new wxCheckBox(this, wxID_ANY, wxT("Free Roam"), wxDefaultPosition, wxSize(30,30)); 62 | 63 | //Make vertical box to put horizontal boxes in 64 | wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL); 65 | 66 | //make horizontal box to put ok and cancel buttons in 67 | wxBoxSizer *hbox5 = new wxBoxSizer(wxHORIZONTAL); 68 | 69 | hbox5->Add(okButton, 1); 70 | hbox5->Add(cancelButton, 1, wxLEFT, 5); 71 | 72 | //add panel of text fields in vertical box 73 | 74 | wxBoxSizer *hboxName = new wxBoxSizer(wxHORIZONTAL); 75 | hboxName->Add(NameText); 76 | hboxName->Add(textFieldName); 77 | 78 | vbox->Add(hboxName, 1, wxEXPAND | wxALL, 10); 79 | 80 | vbox->Add(positionText); 81 | 82 | wxBoxSizer *hboxX = new wxBoxSizer(wxHORIZONTAL); 83 | hboxX->Add(xPositionText); 84 | hboxX->Add(textFieldX); 85 | 86 | vbox->Add(hboxX,1, wxEXPAND | wxALL, 10); 87 | 88 | wxBoxSizer *hboxY = new wxBoxSizer(wxHORIZONTAL); 89 | hboxY->Add(yPositionText); 90 | hboxY->Add(textFieldY); 91 | 92 | vbox->Add(hboxY,1, wxEXPAND | wxALL, 10); 93 | 94 | wxBoxSizer *hboxZ = new wxBoxSizer(wxHORIZONTAL); 95 | hboxZ->Add(zPositionText); 96 | hboxZ->Add(textFieldZ); 97 | 98 | vbox->Add(hboxZ,1, wxEXPAND | wxALL, 10); 99 | 100 | vbox->Add(checkBoxFreeRoam,1, wxEXPAND | wxALL, 10); 101 | 102 | //wxBoxSizer *hboxSoundFile = new wxBoxSizer(wxHORIZONTAL); 103 | //hboxSoundFile->Add(SoundText); 104 | //hboxSoundFile->Add(textFieldSoundFilePath); 105 | //hboxSoundFile->Add(browseButton); 106 | 107 | //vbox->Add(hboxSoundFile,1, wxEXPAND | wxALL, 10); 108 | 109 | vbox->Add(hbox5, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, 10); 110 | 111 | SetSizerAndFit(vbox); 112 | 113 | CreateSoundProducerDialog::initPrivateVariables(); 114 | 115 | //center and show elements in dialog 116 | Centre(); 117 | ShowModal(); 118 | 119 | //destroy when done showing 120 | Destroy(); 121 | } 122 | 123 | void CreateSoundProducerDialog::initPrivateVariables() 124 | { 125 | okClicked = false; 126 | xPosition = 0.0; yPosition = 0.0; zPosition = 0.0; 127 | soundFilePath = ""; 128 | buffer = 0; 129 | } 130 | 131 | void CreateSoundProducerDialog::OnOk(wxCommandEvent& event ) 132 | { 133 | name = textFieldName->GetLineText(0).ToStdString(); 134 | ( textFieldX->GetLineText(0) ).ToDouble(&xPosition); 135 | ( textFieldY->GetLineText(0) ).ToDouble(&yPosition); 136 | ( textFieldZ->GetLineText(0) ).ToDouble(&zPosition); 137 | tempFreeRoamBool = checkBoxFreeRoam->GetValue(); 138 | 139 | okClicked = true; 140 | 141 | CreateSoundProducerDialog::Exit(); 142 | } 143 | 144 | void CreateSoundProducerDialog::OnBrowse(wxCommandEvent& event) 145 | { 146 | wxFileDialog fileDlg(this, _("Choose the WAV file"), wxEmptyString, wxEmptyString, _("WAV file|*.wav|All files|*.*")); 147 | if (fileDlg.ShowModal() == wxID_OK) 148 | { 149 | wxString path = fileDlg.GetPath(); 150 | //use this path in your app 151 | soundFilePath = std::string(path.mb_str()); 152 | std::cout << "Sound file path:" << soundFilePath << std::endl; 153 | 154 | ALuint tempBuffer; 155 | //load sound file 156 | ptrAudioEngine->loadSound(&tempBuffer,soundFilePath); 157 | 158 | //if error in loading, show a message box 159 | if( tempBuffer == 0) 160 | { 161 | std::cout << soundFilePath << "did not load successfully! \n"; 162 | } 163 | //if successfuly 164 | else 165 | { 166 | //put sound file path string into textfieldSoundFilePath 167 | wxString thisPath(soundFilePath); 168 | textFieldSoundFilePath->WriteText(thisPath) ; 169 | //save to buffer 170 | buffer = tempBuffer; 171 | } 172 | } 173 | } 174 | 175 | void CreateSoundProducerDialog::OnCancel(wxCommandEvent& event) 176 | { 177 | okClicked = false; 178 | CreateSoundProducerDialog::Exit(); 179 | } 180 | 181 | void CreateSoundProducerDialog::Exit() 182 | { 183 | if(okButton != nullptr){ delete okButton;} 184 | if(cancelButton != nullptr){delete cancelButton;} 185 | if(textFieldX != nullptr){ delete textFieldX;} 186 | if(textFieldY != nullptr){ delete textFieldY;} 187 | if(textFieldZ != nullptr){ delete textFieldZ;} 188 | 189 | Close( true ); //close window 190 | } 191 | 192 | std::string CreateSoundProducerDialog::getNewName(){return name;} 193 | 194 | std::string& CreateSoundProducerDialog::getSoundFilePath(){return soundFilePath;} 195 | 196 | void CreateSoundProducerDialog::getNewPosition(double& x, double& y, double& z) 197 | { 198 | x = xPosition; 199 | y = yPosition; 200 | z = zPosition; 201 | } 202 | 203 | ALuint& CreateSoundProducerDialog::getBuffer(){return buffer;} 204 | 205 | bool CreateSoundProducerDialog::OkClickedOn(){ return okClicked;} 206 | 207 | bool CreateSoundProducerDialog::getFreeRoamBool(){return tempFreeRoamBool;} 208 | 209 | //Event table for main frame specific events 210 | BEGIN_EVENT_TABLE(CreateSoundProducerDialog, wxDialog) 211 | EVT_BUTTON (ID_OK, CreateSoundProducerDialog::OnOk) 212 | EVT_BUTTON (ID_CANCEL, CreateSoundProducerDialog::OnCancel) 213 | EVT_BUTTON (ID_BROWSE, CreateSoundProducerDialog::OnBrowse) 214 | END_EVENT_TABLE() 215 | -------------------------------------------------------------------------------- /src/EditListenerDialog.cpp: -------------------------------------------------------------------------------- 1 | #include "EditListenerDialog.h" 2 | 3 | EditListenerDialog::EditListenerDialog(const wxString & title, Listener* listener) 4 | : wxDialog(NULL, -1, title, wxDefaultPosition, wxSize(500, 250), wxRESIZE_BORDER) 5 | { 6 | 7 | EditListenerDialog::initPrivateVariables(); 8 | 9 | //make horizontal box to put names in 10 | wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL); 11 | 12 | //make vertical box to put display info to edit 13 | wxBoxSizer *vboxEdit = new wxBoxSizer(wxVERTICAL); 14 | 15 | //initialize text fields 16 | wxFloatingPointValidator validator(2,nullptr,wxNUM_VAL_ZERO_AS_BLANK); 17 | validator.SetRange(-10.00,10.00); // set allowable range 18 | 19 | 20 | 21 | textFieldX = new wxTextCtrl(this,-1, "", 22 | wxPoint(150, 60), wxSize(80,20), 23 | wxTE_PROCESS_ENTER, 24 | validator, // associate the text box with the desired validator 25 | wxT("")); 26 | 27 | textFieldY = new wxTextCtrl(this,-1, "", 28 | wxPoint(150, 80), wxSize(80,20), 29 | wxTE_PROCESS_ENTER, 30 | validator, // associate the text box with the desired validator 31 | wxT("")); 32 | 33 | textFieldZ = new wxTextCtrl(this,-1, "", 34 | wxPoint(150, 100), wxSize(80,20), 35 | wxTE_PROCESS_ENTER, 36 | validator, // associate the text box with the desired validator 37 | wxT("")); 38 | 39 | 40 | //reset text fields 41 | textFieldX->Clear(); 42 | textFieldY->Clear(); 43 | textFieldZ->Clear(); 44 | 45 | 46 | 47 | //initialize text to the left of fields 48 | wxStaticText* positionText = new wxStaticText(this, -1, wxT("Position :"), wxPoint(20, 40)); 49 | wxStaticText* xPositionText = new wxStaticText(this, -1, wxT("X :"), wxPoint(40, 60)); 50 | wxStaticText* yPositionText = new wxStaticText(this, -1, wxT("Y :"), wxPoint(40, 80)); 51 | wxStaticText* zPositionText = new wxStaticText(this, -1, wxT("Z :"), wxPoint(40, 100)); 52 | 53 | //add textfields to edit box 54 | vboxEdit->Add(positionText, 0, wxALL, 1); 55 | vboxEdit->Add(xPositionText, 0, wxALL, 1); 56 | vboxEdit->Add(textFieldX, 0, wxALL, 5); 57 | vboxEdit->Add(yPositionText, 0, wxALL, 1); 58 | vboxEdit->Add(textFieldY, 0, wxALL, 5); 59 | vboxEdit->Add(zPositionText, 0, wxALL, 1); 60 | vboxEdit->Add(textFieldZ, 0, wxALL, 5); 61 | 62 | //add checkmark box to determine if listener can roam freely in world or is controlled by listener track 63 | checkBoxFreeRoam = new wxCheckBox(this, wxID_ANY, wxT("Free Roam"), wxDefaultPosition, wxSize(30,30)); 64 | checkBoxFreeRoam->Bind(wxEVT_CHECKBOX, &EditListenerDialog::OnFreeRoamCheckBoxClicked,this); 65 | 66 | //add checkmark box to determine if listener orientation is controlled by external device or is controlled by listener track 67 | checkBoxExternalDeviceOrientation = new wxCheckBox(this, wxID_ANY, wxT("External Device Orientation"), wxDefaultPosition, wxSize(30,30)); 68 | checkBoxExternalDeviceOrientation->Bind(wxEVT_CHECKBOX, &EditListenerDialog::OnExternalDeviceOrientationCheckBoxClicked,this); 69 | 70 | 71 | 72 | vboxEdit->Add(checkBoxFreeRoam, 1 , wxEXPAND | wxALL, 1); 73 | vboxEdit->Add(checkBoxExternalDeviceOrientation, 1 , wxEXPAND | wxALL, 1); 74 | 75 | hbox->Add(vboxEdit, 1, wxEXPAND | wxALL, 10); 76 | 77 | 78 | //initialize Ok and Cancel buttons 79 | okButton = new wxButton(this, wxID_ANY, wxT("Ok"), wxDefaultPosition, wxSize(70, 30) ); 80 | okButton->Bind(wxEVT_BUTTON, &EditListenerDialog::OnOk,this); 81 | 82 | cancelButton = new wxButton(this, wxID_ANY, wxT("Cancel"), wxDefaultPosition, wxSize(70, 30) ); 83 | cancelButton->Bind(wxEVT_BUTTON, &EditListenerDialog::OnCancel,this); 84 | 85 | applyButton = new wxButton(this, wxID_ANY, wxT("Apply"), wxDefaultPosition, wxSize(70, 30) ); 86 | applyButton->Bind(wxEVT_BUTTON, &EditListenerDialog::OnApply,this); 87 | 88 | //make horizontal box to put ok and cancel buttons in 89 | wxBoxSizer *hboxBottom = new wxBoxSizer(wxHORIZONTAL); 90 | 91 | hboxBottom->Add(applyButton, 0, wxRIGHT, 5); 92 | hboxBottom->Add(okButton, 0); 93 | hboxBottom->Add(cancelButton, 0, wxLEFT, 5); 94 | 95 | //Make vertical box to put everything in 96 | wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL); 97 | 98 | //add panel of text fields in vertical box 99 | vbox->Add(hbox, 1, wxEXPAND | wxALL, 10); 100 | vbox->Add(hboxBottom, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, 10); 101 | 102 | SetSizerAndFit(vbox); 103 | 104 | //update position text fields and checkbox to have current properties of listener 105 | ptrListener = listener; 106 | if(ptrListener == nullptr){std::cout << "listener pointer is nullptr! \n";} 107 | else 108 | { 109 | (*textFieldX) << ptrListener->getPositionX(); 110 | (*textFieldY) << ptrListener->getPositionY(); 111 | (*textFieldZ) << ptrListener->getPositionZ(); 112 | 113 | 114 | tempFreeRoamBool = ptrListener->GetListenerFreeRoamBool(); 115 | checkBoxFreeRoam->SetValue(ptrListener->GetListenerFreeRoamBool()); 116 | 117 | tempExternalDeviceOrientation = ptrListener->GetListenerExternalDeviceOrientationBool(); 118 | checkBoxExternalDeviceOrientation->SetValue(ptrListener->GetListenerExternalDeviceOrientationBool()); 119 | } 120 | 121 | //center and show elements in dialog 122 | Centre(); 123 | ShowModal(); 124 | 125 | //destroy when done showing 126 | Destroy(); 127 | } 128 | 129 | void EditListenerDialog::initPrivateVariables() 130 | { 131 | ptrListener = nullptr; 132 | textFieldX = nullptr; textFieldY = nullptr; textFieldZ = nullptr; 133 | 134 | applyButton = nullptr; okButton = nullptr; cancelButton = nullptr; 135 | } 136 | 137 | void EditListenerDialog::ChangeListenerAttributes() 138 | { 139 | if(ptrListener != nullptr) 140 | { 141 | 142 | //change position of selected sound producer based on what is in textfields 143 | double xPosition, yPosition, zPosition; 144 | ( textFieldX->GetLineText(0) ).ToDouble(&xPosition); 145 | ( textFieldY->GetLineText(0) ).ToDouble(&yPosition); 146 | ( textFieldZ->GetLineText(0) ).ToDouble(&zPosition); 147 | float x = xPosition; 148 | float y = yPosition; 149 | float z = zPosition; 150 | ptrListener->setPositionX(x); 151 | ptrListener->setPositionY(y); 152 | ptrListener->setPositionZ(z); 153 | 154 | //change free roam status 155 | ptrListener->SetListenerFreeRoamBool(tempFreeRoamBool); 156 | 157 | //change external device orientation status 158 | ptrListener->SetListenerExternalDeviceOrientationBool(tempExternalDeviceOrientation); 159 | 160 | } 161 | 162 | } 163 | 164 | void EditListenerDialog::OnFreeRoamCheckBoxClicked(wxCommandEvent& event) 165 | { 166 | tempFreeRoamBool = checkBoxFreeRoam->GetValue(); 167 | } 168 | 169 | 170 | void EditListenerDialog::OnExternalDeviceOrientationCheckBoxClicked(wxCommandEvent& event) 171 | { 172 | tempExternalDeviceOrientation = checkBoxExternalDeviceOrientation->GetValue(); 173 | } 174 | 175 | void EditListenerDialog::OnApply(wxCommandEvent& event) 176 | { 177 | EditListenerDialog::ChangeListenerAttributes(); 178 | } 179 | 180 | void EditListenerDialog::OnOk(wxCommandEvent& event ) 181 | { 182 | EditListenerDialog::ChangeListenerAttributes(); 183 | 184 | EditListenerDialog::Exit(); 185 | } 186 | 187 | void EditListenerDialog::OnCancel(wxCommandEvent& event) 188 | { 189 | EditListenerDialog::Exit(); 190 | } 191 | 192 | void EditListenerDialog::Exit() 193 | { 194 | if(okButton != nullptr){ delete okButton;} 195 | if(applyButton != nullptr){delete applyButton;} 196 | if(cancelButton != nullptr){delete cancelButton;} 197 | if(textFieldX != nullptr){ delete textFieldX;} 198 | if(textFieldY != nullptr){ delete textFieldY;} 199 | if(textFieldZ != nullptr){ delete textFieldZ;} 200 | if(checkBoxFreeRoam != nullptr){delete checkBoxFreeRoam;} 201 | if(checkBoxExternalDeviceOrientation != nullptr){delete checkBoxExternalDeviceOrientation;} 202 | Close( true ); //close window 203 | } 204 | --------------------------------------------------------------------------------