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 support for filenames beginning with a dash #149

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ideoforms
Copy link

I have a use case which requires support for filenames beginning with a dash (“-”). However, this is currently parsed as an extra argument, and causes sox/soxi to bail with an exit code of 1.

This PR addresses the issue by inserting a double-dash immediately before the filename (in input and output cases), and incorporates unit tests for these cases.

Please let me know if you have any concerns or would like any changes. Thanks for the excellent library!

@coveralls
Copy link

Coverage Status

Coverage increased (+0.009%) to 98.832% when pulling 8b77a30 on ideoforms:master into 0a428b8 on rabitt:master.

@lostanlen
Copy link
Member

@rabitt what are your thoughts?

@lostanlen
Copy link
Member

lostanlen commented Jan 5, 2024

Looking at this PR again today, i feel like this program flow:

if input_filepath != "-n":
    args.append("--")
args.append(input_filepath)

appears enough times in the PR to warrant being a pysox function of its own, with a unit test.
The -n case corresponds to a null filepath. Quote from the docs:

              This can be used in place of an  input  or  output  filename  to
              specify that a ‘null file’ is to be used.  Note that here, ‘null
              file’ refers to a SoX‐specific mechanism and is not  related  to
              any operating‐system mechanism with a similar name.

              Using a null file to input audio is equivalent to using a normal
              audio file that contains an infinite amount of silence,  and  as
              such  is  not  generally  useful unless used with an effect that
              specifies a finite time length (such as trim or synth).

              Using a null file to output  audio  amounts  to  discarding  the
              audio and is useful mainly with effects that produce information
              about the audio instead of affecting it (such  as  noiseprof  or
              stat).

Relatedly, does this PR support --null as filepath? (full-word synonym to -n)

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.

None yet

3 participants