Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit tests, refactor, new slideshow feature, other improvements #55

Merged
merged 29 commits into from
Aug 6, 2014

Conversation

leguye
Copy link

@leguye leguye commented Mar 14, 2014

This pull requests adds unit tests, refactors the ly2video into several modules and classes and adds new features.

New major features:

  • the video can be split into several areas
  • this enables a slide show (--slide-show), allowing to put fixed pictures into one zone

Examples: with a slide show and with several score scrolling modes

Other new features and improvements:

Before I began to code I made some unit tests (see issue #25) for the VideoFrameWriter class. The tested methods were:

  • the midi/time calculation methods: ticksToSecs(), secsElapsedForTempoChanges()
  • the cropping methods: isLineBlank(), getTopAndBottomMarginSizes(), findStaffLinesInImage(), cropFrame()

The code of methods write() and writeVideoFrames() were difficult to test because they don't return any value. They just put image files on disk. But some code was able to be tested when isolated into methods:

  • the score image following
  • the cursor drawing
  • the sychronisation data handling

First of all the video.ScoreImage class has been created. This class manages:

  • the image following: currentXposition(), travelToNextNote(),
    moveToNextNote(), notesXpositions
  • the frame drawing: makeFrame()

The sychro.Timecode class handles the synchronisation data: atEnd(), gotToNextNote(), nbFramesToNextNote() methods. I have used the Observer design pattern to produce frames. The timecode object is a kind of 'conductor' of the process.

video.ScoreImage inherits the video.Media class and the VideoFrameWriter can now manage severals medias. So the push method can be used to stack medias one above the other. I added the new media video.SlideShow to be able to run a slide show composed of several pictures as the music is playing. A horizontal line cursor can be added if needed.

The very first unit tests had been conserved along all the commits although the code architecture has evolved. This new architecture permits to create near to 50 unit tests for the frame writing part of ly2video.

leguye and others added 29 commits January 7, 2014 11:09
Eclipse metadata, Emacs *~ and .pyc are now ignored.
Tested functions:
	* findStaffLinesInImage()
Tested classes:
	* VideoFrameWriter:
		- image handling methods:
			. isLineBlank()
        		. getTopAndBottomMarginSizes()
			. getCropTopAndBottom()
			. cropFrame()
		- time handling methods:
			. ticksToSecs()
			. secsElapsedForTempoChanges()
To maintain the code more easily, the program will be split into several modules.
setDebug() and setRunDir() functions are handling global var DEBUG and runDir.
Move VideoFrameWriter and some image scanning functions into a new 'video' module.
Update unit tests.
Avoid an 'undefined var' at execution?
…avelling

Some VideoFrameWriter methods are now moved to this class.
The getCropTopAndBottomMarginSizes() method is replaced by the topCroppable() and
bottomCroppable() methods which respectivly return the number of pixels the image can
be cropped on top an bottom.
An instance is now used by VideoFrameWriter.

Some unused code has been removed in VideoFrameWriter (write and secsElapsedForTempoChanges)
Update the tests for the new class ScoreImage.
The tests of image handling methods are moved to the ScoreImageTest test class.

Tested functions:
	* findStaffLinesInImage()
Tested classes:
    	* VideoFrameWriter:
    		. ticksToSecs()
    		. secsElapsedForTempoChanges()
	* ScoreImage
    		. __isLineBlank()
    		. __setCropTopAndBottom()
    		. __cropFrame()
		. topCroppable()
		. bottomCroppable()
		. makeFrame()
...instead of image notes indexes.
Less dependant from the scoreImage class.
The ScoreImage instance of VideoFrameWriter can now be set as a public property.
Some parameters of the VideoFrameWriter constructor are removed and the
write() method has now no parameter. These parameters are attached to
the ScoreImage instance.
Implements a measure cursor that is slightly less intrusive than the line
cursor following each note.
Updates writeSpaceTimeDumper() function the measures bars positions.
New function getMeasuresIndices().
These options are added to be more coherent with --measure-cursor, and to allow no cursor at all.
… video

VideoFrameWriter is now able to push up medias.
This cursor can be used when the slide show displays some structure diagram.
Some hard coded values should be set by command line options...
Deletes height and width in VideoFrameWriter constructor
(No height limit, score)
Tested classes:
	* VideoFrameWriter:
    		. push()
    		. scoreImageSetter()
Time handling methods are moved to this class.
The design pattern 'Observer' is used.
New 'synchro' module.
Add tests for the new class TimeCode, update some tests.
Some new fonctional tests (testCompleteFollowing)

Tested classes:
	* TimeCode:
		. ticksToSecs()
		. secsElapsedForTempoChanges()
		. nbFramesToNextNote()
		. goToNextNote()
		. atEnd()
	* ScoreImage:
		. currentXposition
		. moveToNextNote()
		. cropFrame()
As of Python 2.7, optparse is deprecated in favour of argparse.
@aspiers
Copy link
Owner

aspiers commented Aug 6, 2014

This looks like excellent work to me - I'm really delighted by the high quality of every commit I looked at. Unfortunately I have still not managed to find time to review it thoroughly, so I think the best thing to do is merge it, and if other users encounter any issues with the updated code, we can deal with them individually.

Thank you again for this amazing contribution!

aspiers added a commit that referenced this pull request Aug 6, 2014
Add unit tests, refactor, new slideshow feature, other improvements
@aspiers aspiers merged commit a10813b into aspiers:master Aug 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants