Page 1 of 1

Timeline Track Editor wxWidgets only

Posted: Mon May 27, 2019 8:00 pm
by experimental-design
I needed some sort of GUI with a timeline and track editor for my binaural audio editor to change a variable with time.

I noticed that there wasn't code for a timeline track editor for wxWidgets that was freely available and easy to copy and integrate.

So I made my own and released it under the BSD license so anyone can copy it and use it for their open-source or closed-source projects.

https://github.com/adct-the-experimente ... ack-editor

Try it out and let me know if you find some bugs or have ideas to improve it.

The project aims to be non-application specific.

In its current state:
-Can add point to a graph with a left click on the mouse.
-Can remove point from the graph with right click on the mouse.
-Can change double-type variable according to information represented by points on the graph.
-Can add any number of tracks to change variables.

Re: Timeline Track Editor wxWidgets only

Posted: Fri May 31, 2019 11:27 pm
by experimental-design
Big Update:
-Added ability to pass functions to execute during playback only during state of play.
-Updated README.md for better instructions.

For an example of how to create a custom class that uses DoubleTrack as a member in a Track derived class see
soundproducer-track.cpp and osgViewerWx.cpp in github.com/adct-the-experimenter/binaural-audio-editor .

IMPORTANT NOTE: Make sure double track gets added to timeframe not through inheritance but explicitly by TimeFrame class object!

Here is a video of the timeline-track-editor GUI code in use for my other project Binaural Audio Editor.
https://www.youtube.com/watch?v=41bjS_eg-Ps

Re: Timeline Track Editor wxWidgets only

Posted: Tue Jun 11, 2019 2:09 am
by experimental-design
Update 3:

Added ability to call separate functions for separate playback states such as play, pause, rewind, fast forward, null(state after stop button pressed).

Re: Timeline Track Editor wxWidgets only

Posted: Wed Jun 19, 2019 6:09 pm
by experimental-design
Update 4:
Added capability to handle audio. OpenAL Soft and libsndfile libraries need to be installed.

-Added AudioTrack to handle data operations and graphing for audio.
-Added StereoAudioTrack to graph mono audio data and stereo audio data and audio playback.
-Added MonoAudioTrack to graph mono audio data and audio playback.

The audio playback does not work very well at the moment, but it does currently load and play audio from start to finish.

If anyone wants to graph audio, look at AudioTrack and AudioGraph classes.

The general process for graphing audio.
1. Use a library(libsndfile,FFmpeg,LAME,etc) to open audio files and do data reading and writing.

2. Load audio data into a vector of double, or int, or uint16_t, etc. In my case, I did vector of double.

3. Read each sample(index) in vector containing audio data.
Have some code to get the max value every n samples e.g. from samples 0-499, get max value and save it along with the sample number.
Restart process at sample 500. Look at samples from 500-999 to get next max and sample number where max is.
Cap max at +1.
*Important Note: Stereo has left channel samples and right channel samples every other sample i.e. sample 0 is for left channel sample 1 is for right channel.

4.After reading through the vector, convert max values into a y-axis coordinate for graph,
and convert sample numbers where max values occur to time values with sample rate, then to x-axis coordinate for time axis.
Save those graph points into a vector in chronological order.
*Note: time value = sample / sample_rate; // sample # * (1s / (# of samples in 1 second) ) = time in seconds

5. Use wxPaintDC Draw circle to draw points to graph and use draw line function to draw lines between points in vector.

Re: Timeline Track Editor wxWidgets only

Posted: Mon Jul 01, 2019 8:49 pm
by experimental-design
Minor Update 4.1

-Improved graphing of audio to be more accurate.
-Fix most audio playback issues. Can now start audio playback at any point and rewind and fast forward audio.

Re: Timeline Track Editor wxWidgets only

Posted: Tue Jul 02, 2019 5:36 am
by doublemax
Although i currently have no need for a control like this, i just wanted to say thanks for posting this. I felt sorry that you didn't get any feedback :)

Re: Timeline Track Editor wxWidgets only

Posted: Tue Jul 02, 2019 4:04 pm
by experimental-design
Thanks! You made my day.

I haven't gotten feedback, but the good news is most of the views on the github project come from this forum.

Re: Timeline Track Editor wxWidgets only

Posted: Sat Jul 06, 2019 9:42 pm
by experimental-design
Update 5:
I fixed a critical bug that caused the program to crash whenever a graph point was removed!

It was just a really dumb mistake of passing the last iterator from vector and assuming that iterator was the iterator pointing to the element that was pushed back into vector. It was actually the second-to-last iterator that points to the new element pushed back into vector.

Edit:
Never mind. It is only partially fixed

Edit 2:
I have it fully fixed now. Multiple graph points can be removed without program crashing.

Re: Timeline Track Editor wxWidgets only

Posted: Tue Aug 27, 2019 8:32 pm
by experimental-design
Update 6:
I fixed the large CPU usage issue.

CPU usage has drastically decreased to little more than half of its usage and performance has greatly improved.

It was fixed by calling Refresh() only when needed after a point was added to or removed from graph.
Also event.Skip() was called at end of respective functions that ran in paint and scroll events.