nwhitehead / pyfluidsynth

Python bindings for FluidSynth
GNU Lesser General Public License v2.1
197 stars 56 forks source link

Add local_file_path() function #59

Closed cclauss closed 4 months ago

cclauss commented 4 months ago

Let's add a local_file_path() function so that we can sfid = fs.sfload(local_file_path("example.sf2")) reliably no matter which directory we are in.

def local_file_path(file_name: str) -> str:
    """
    Return a file path to a file that is in the same directory as this file.
    """
    from os.path import dirname, join

    return join(dirname(__file__), file_name)