├── .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