Index: python/demos/demo_bpm_extract.py
===================================================================
--- python/demos/demo_bpm_extract.py	(revision 357f81e2b95e86c7378fba81335b56a78ccee7b6)
+++ python/demos/demo_bpm_extract.py	(revision 4bc10e20d16aaaefc7d6b4942a666facddd8e090)
@@ -23,5 +23,5 @@
             pass
         else:
-            print("unknown mode {:s}".format(params.mode))
+            raise ValueError("unknown mode {:s}".format(params.mode))
     # manual settings
     if 'samplerate' in params:
@@ -70,7 +70,7 @@
     parser.add_argument('-m', '--mode',
             help="mode [default|fast|super-fast]",
-            dest="mode")
+            dest="mode", default='default')
     parser.add_argument('sources',
-            nargs='*',
+            nargs='+',
             help="input_files")
     args = parser.parse_args()
Index: python/ext/aubiomodule.c
===================================================================
--- python/ext/aubiomodule.c	(revision 357f81e2b95e86c7378fba81335b56a78ccee7b6)
+++ python/ext/aubiomodule.c	(revision 4bc10e20d16aaaefc7d6b4942a666facddd8e090)
@@ -118,5 +118,7 @@
   smpl_t output;
 
-  if (!PyArg_ParseTuple (args, "|" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR , &input, &samplerate, &fftsize)) {
+  if (!PyArg_ParseTuple (args,
+        "" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR,
+        &input, &samplerate, &fftsize)) {
     return NULL;
   }
@@ -133,5 +135,7 @@
   smpl_t output;
 
-  if (!PyArg_ParseTuple (args, "|" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR , &input, &samplerate, &fftsize)) {
+  if (!PyArg_ParseTuple (args,
+        "" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR,
+        &input, &samplerate, &fftsize)) {
     return NULL;
   }
@@ -148,5 +152,7 @@
   smpl_t output;
 
-  if (!PyArg_ParseTuple (args, "|" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR, &input, &samplerate, &fftsize)) {
+  if (!PyArg_ParseTuple (args,
+        "" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR,
+        &input, &samplerate, &fftsize)) {
     return NULL;
   }
@@ -163,5 +169,7 @@
   smpl_t output;
 
-  if (!PyArg_ParseTuple (args, "|" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR, &input, &samplerate, &fftsize)) {
+  if (!PyArg_ParseTuple (args,
+        "" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR,
+        &input, &samplerate, &fftsize)) {
     return NULL;
   }
Index: python/ext/py-filterbank.c
===================================================================
--- python/ext/py-filterbank.c	(revision 357f81e2b95e86c7378fba81335b56a78ccee7b6)
+++ python/ext/py-filterbank.c	(revision 4bc10e20d16aaaefc7d6b4942a666facddd8e090)
@@ -95,5 +95,5 @@
   if (self->vec.length != self->win_s / 2 + 1) {
     PyErr_Format(PyExc_ValueError,
-                 "input cvec has length %d, but fft expects length %d",
+                 "input cvec has length %d, but filterbank expects length %d",
                  self->vec.length, self->win_s / 2 + 1);
     return NULL;
@@ -140,5 +140,5 @@
   if (err > 0) {
     PyErr_SetString (PyExc_ValueError,
-        "error when setting filter to A-weighting");
+        "error when running set_triangle_bands");
     return NULL;
   }
@@ -159,5 +159,5 @@
   if (err > 0) {
     PyErr_SetString (PyExc_ValueError,
-        "error when setting filter to A-weighting");
+        "error when running set_mel_coeffs_slaney");
     return NULL;
   }
Index: python/lib/aubio/cmd.py
===================================================================
--- python/lib/aubio/cmd.py	(revision 357f81e2b95e86c7378fba81335b56a78ccee7b6)
+++ python/lib/aubio/cmd.py	(revision 4bc10e20d16aaaefc7d6b4942a666facddd8e090)
@@ -256,4 +256,7 @@
                 action = "store", dest = "cut_until_nslices", default = None,
                 help="how many extra slices should be added at the end of each slice")
+        self.add_argument("--create-first",
+                action = "store_true", dest = "create_first", default = False,
+                help="always include first slice")
 
 # some utilities
@@ -512,5 +515,22 @@
 def main():
     parser = aubio_parser()
-    args = parser.parse_args()
+    if sys.version_info[0] != 3:
+        # on py2, create a dummy ArgumentParser to workaround the
+        # optional subcommand issue. See https://bugs.python.org/issue9253
+        # This ensures that:
+        #  - version string is shown when only '-V' is passed
+        #  - help is printed if  '-V' is passed with any other argument
+        #  - any other argument get forwarded to the real parser
+        parser_root = argparse.ArgumentParser(add_help=False)
+        parser_root.add_argument('-V', '--version', help="show version",
+                action="store_true", dest="show_version")
+        args, extras = parser_root.parse_known_args()
+        if args.show_version == False: # no -V, forward to parser
+            args = parser.parse_args(extras, namespace=args)
+        elif len(extras) != 0: # -V with other arguments, print help
+            parser.print_help()
+            sys.exit(1)
+    else: # in py3, we can simply use parser directly
+        args = parser.parse_args()
     if 'show_version' in args and args.show_version:
         sys.stdout.write('aubio version ' + aubio.version + '\n')
Index: python/lib/aubio/cut.py
===================================================================
--- python/lib/aubio/cut.py	(revision 357f81e2b95e86c7378fba81335b56a78ccee7b6)
+++ python/lib/aubio/cut.py	(revision 4bc10e20d16aaaefc7d6b4942a666facddd8e090)
@@ -102,5 +102,5 @@
     s = source(source_uri, samplerate, hopsize)
     if samplerate == 0:
-        samplerate = s.get_samplerate()
+        samplerate = s.samplerate
         options.samplerate = samplerate
 
@@ -151,5 +151,6 @@
                 timestamps, timestamps_end = timestamps_end,
                 output_dir = options.output_directory,
-                samplerate = options.samplerate)
+                samplerate = options.samplerate,
+                create_first = options.create_first)
 
 def main():
Index: python/lib/aubio/midiconv.py
===================================================================
--- python/lib/aubio/midiconv.py	(revision 357f81e2b95e86c7378fba81335b56a78ccee7b6)
+++ python/lib/aubio/midiconv.py	(revision 4bc10e20d16aaaefc7d6b4942a666facddd8e090)
@@ -2,7 +2,9 @@
 """ utilities to convert midi note number to and from note names """
 
-__all__ = ['note2midi', 'midi2note', 'freq2note']
+__all__ = ['note2midi', 'midi2note', 'freq2note', 'note2freq']
 
 import sys
+from ._aubio import freqtomidi, miditofreq
+
 py3 = sys.version_info[0] == 3
 if py3:
@@ -25,8 +27,9 @@
     _valid_octaves = range(-1, 10)
     if not isinstance(note, str_instances):
-        raise TypeError("a string is required, got %s (%s)" % (note, str(type(note))))
+        msg = "a string is required, got {:s} ({:s})"
+        raise TypeError(msg.format(str(type(note)), repr(note)))
     if len(note) not in range(2, 5):
-        raise ValueError("string of 2 to 4 characters expected, got %d (%s)" \
-                         % (len(note), note))
+        msg = "string of 2 to 4 characters expected, got {:d} ({:s})"
+        raise ValueError(msg.format(len(note), note))
     notename, modifier, octave = [None]*3
 
@@ -52,5 +55,6 @@
         raise ValueError("%s is not a valid octave" % octave)
 
-    midi = 12 + octave * 12 + _valid_notenames[notename] + _valid_modifiers[modifier]
+    midi = 12 + octave * 12 + _valid_notenames[notename] \
+            + _valid_modifiers[modifier]
     if midi > 127:
         raise ValueError("%s is outside of the range C-2 to G8" % note)
@@ -62,10 +66,35 @@
         raise TypeError("an integer is required, got %s" % midi)
     if midi not in range(0, 128):
-        raise ValueError("an integer between 0 and 127 is excepted, got %d" % midi)
-    _valid_notenames = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']
+        msg = "an integer between 0 and 127 is excepted, got {:d}"
+        raise ValueError(msg.format(midi))
+    _valid_notenames = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#',
+            'A', 'A#', 'B']
     return _valid_notenames[midi % 12] + str(int(midi / 12) - 1)
 
 def freq2note(freq):
     " convert frequency in Hz to nearest note name, e.g. [0, 22050.] -> [C-1, G9] "
-    from aubio import freqtomidi
-    return midi2note(int(freqtomidi(freq)))
+    nearest_note = int(freqtomidi(freq) + .5)
+    return midi2note(nearest_note)
+
+def note2freq(note):
+    """Convert note name to corresponding frequency, in Hz.
+
+    Parameters
+    ----------
+    note : str
+        input note name
+
+    Returns
+    -------
+    freq : float [0, 23000[
+        frequency, in Hz
+
+    Example
+    -------
+    >>> aubio.note2freq('A4')
+    440
+    >>> aubio.note2freq('A3')
+    220.1
+    """
+    midi = note2midi(note)
+    return miditofreq(midi)
Index: python/lib/aubio/slicing.py
===================================================================
--- python/lib/aubio/slicing.py	(revision 357f81e2b95e86c7378fba81335b56a78ccee7b6)
+++ python/lib/aubio/slicing.py	(revision 4bc10e20d16aaaefc7d6b4942a666facddd8e090)
@@ -7,5 +7,6 @@
 
 def slice_source_at_stamps(source_file, timestamps, timestamps_end=None,
-                           output_dir=None, samplerate=0, hopsize=256):
+                           output_dir=None, samplerate=0, hopsize=256,
+                           create_first=False):
     """ slice a sound file at given timestamps """
 
@@ -13,5 +14,5 @@
         raise ValueError("no timestamps given")
 
-    if timestamps[0] != 0:
+    if timestamps[0] != 0 and create_first:
         timestamps = [0] + timestamps
         if timestamps_end is not None:
@@ -19,5 +20,7 @@
 
     if timestamps_end is not None:
-        if len(timestamps_end) != len(timestamps):
+        if len(timestamps_end) == len(timestamps) - 1:
+            timestamps_end = timestamps_end + [_max_timestamp]
+        elif len(timestamps_end) != len(timestamps):
             raise ValueError("len(timestamps_end) != len(timestamps)")
     else:
@@ -49,5 +52,5 @@
         vec, read = _source.do_multi()
         # if the total number of frames read will exceed the next region start
-        if len(regions) and total_frames + read >= regions[0][0]:
+        while len(regions) and total_frames + read >= regions[0][0]:
             #print "getting", regions[0], "at", total_frames
             # get next region
@@ -76,5 +79,5 @@
                     # write remaining samples from current region
                     _sink.do_multi(vec[:, start:remaining], remaining - start)
-                    #print "closing region", "remaining", remaining
+                    #print("closing region", "remaining", remaining)
                     # close this file
                     _sink.close()
@@ -83,4 +86,7 @@
                 _sink.do_multi(vec[:, start:read], read - start)
         total_frames += read
+        # remove old slices
+        slices = list(filter(lambda s: s['end_stamp'] > total_frames,
+            slices))
         if read < hopsize:
             break
Index: python/tests/test_aubio_cmd.py
===================================================================
--- python/tests/test_aubio_cmd.py	(revision 357f81e2b95e86c7378fba81335b56a78ccee7b6)
+++ python/tests/test_aubio_cmd.py	(revision 4bc10e20d16aaaefc7d6b4942a666facddd8e090)
@@ -20,11 +20,14 @@
 
     def test_samples2seconds(self):
-        self.assertEqual(aubio.cmd.samples2seconds(3200, 32000), "0.100000\t")
+        self.assertEqual(aubio.cmd.samples2seconds(3200, 32000),
+                "0.100000\t")
 
     def test_samples2milliseconds(self):
-        self.assertEqual(aubio.cmd.samples2milliseconds(3200, 32000), "100.000000\t")
+        self.assertEqual(aubio.cmd.samples2milliseconds(3200, 32000),
+                "100.000000\t")
 
     def test_samples2samples(self):
-        self.assertEqual(aubio.cmd.samples2samples(3200, 32000), "3200\t")
+        self.assertEqual(aubio.cmd.samples2samples(3200, 32000),
+                "3200\t")
 
 if __name__ == '__main__':
Index: python/tests/test_note2midi.py
===================================================================
--- python/tests/test_note2midi.py	(revision 357f81e2b95e86c7378fba81335b56a78ccee7b6)
+++ python/tests/test_note2midi.py	(revision 4bc10e20d16aaaefc7d6b4942a666facddd8e090)
@@ -4,5 +4,5 @@
 from __future__ import unicode_literals
 
-from aubio import note2midi, freq2note
+from aubio import note2midi, freq2note, note2freq, float_type
 from nose2.tools import params
 import unittest
@@ -112,7 +112,24 @@
 class freq2note_simple_test(unittest.TestCase):
 
-    def test_freq2note(self):
+    def test_freq2note_above(self):
         " make sure freq2note(441) == A4 "
         self.assertEqual("A4", freq2note(441))
+
+    def test_freq2note_under(self):
+        " make sure freq2note(439) == A4 "
+        self.assertEqual("A4", freq2note(439))
+
+class note2freq_simple_test(unittest.TestCase):
+
+    def test_note2freq(self):
+        " make sure note2freq('A3') == 220"
+        self.assertEqual(220, note2freq("A3"))
+
+    def test_note2freq_under(self):
+        " make sure note2freq(A4) == 440"
+        if float_type == 'float32':
+            self.assertEqual(440, note2freq("A4"))
+        else:
+            self.assertLess(abs(note2freq("A4")-440), 1.e-12)
 
 if __name__ == '__main__':
Index: python/tests/test_slicing.py
===================================================================
--- python/tests/test_slicing.py	(revision 357f81e2b95e86c7378fba81335b56a78ccee7b6)
+++ python/tests/test_slicing.py	(revision 4bc10e20d16aaaefc7d6b4942a666facddd8e090)
@@ -24,16 +24,24 @@
     def test_slice_start_only_no_zero(self):
         regions_start = [i*1000 for i in range(1, n_slices)]
-        slice_source_at_stamps(self.source_file, regions_start, output_dir = self.output_dir)
+        slice_source_at_stamps(self.source_file, regions_start,
+                output_dir = self.output_dir, create_first=True)
 
     def test_slice_start_beyond_end(self):
         regions_start = [i*1000 for i in range(1, n_slices)]
         regions_start += [count_samples_in_file(self.source_file) + 1000]
-        slice_source_at_stamps(self.source_file, regions_start, output_dir = self.output_dir)
+        slice_source_at_stamps(self.source_file, regions_start,
+                output_dir = self.output_dir, create_first=True)
 
     def test_slice_start_every_blocksize(self):
         hopsize = 200
-        regions_start = [i*hopsize for i in range(1, n_slices)]
+        regions_start = [i*hopsize for i in range(0, n_slices)]
         slice_source_at_stamps(self.source_file, regions_start, output_dir = self.output_dir,
                 hopsize = 200)
+
+    def test_slice_start_every_half_blocksize(self):
+        hopsize = 200
+        regions_start = [i*hopsize//2 for i in range(0, n_slices)]
+        slice_source_at_stamps(self.source_file, regions_start,
+                output_dir = self.output_dir, hopsize = 200)
 
     def tearDown(self):
@@ -92,4 +100,17 @@
             "number of samples written different from number of original samples")
 
+    def test_slice_start_and_ends_with_missing_end(self):
+        regions_start = [i*1000 for i in range(n_slices)]
+        regions_ends = [r-1 for r in regions_start[1:]]
+        slice_source_at_stamps(self.source_file, regions_start, regions_ends,
+                output_dir = self.output_dir)
+        written_samples = count_samples_in_directory(self.output_dir)
+        original_samples = count_samples_in_file(self.source_file)
+        total_files = count_files_in_directory(self.output_dir)
+        assert_equal(n_slices, total_files,
+            "number of slices created different from expected")
+        assert_equal(written_samples, original_samples,
+            "number of samples written different from number of original samples")
+
     def tearDown(self):
         shutil.rmtree(self.output_dir)
@@ -134,5 +155,5 @@
         regions_end = None
         slice_source_at_stamps (self.source_file, regions_start, regions_end,
-                output_dir = self.output_dir)
+                output_dir = self.output_dir, create_first=True)
         total_files = count_files_in_directory(self.output_dir)
         assert_equal(n_slices, total_files,
