Package: nightcore
Nightcore - Easily modify speed/pitchA focused CLI and API for changing the pitch and speed of audio.Requires FFmpeg.Installation|CLI Usage|API UsageI had the idea for this a long time ago, and wanted to make it to prove a point. This program is not intended for, nor should it be used for, copyright infringement and piracy.Nightcore is not, and has never been, fair use.InstallationFFmpeg is a required dependency-see herefor instructions on how to set it up!With FFmpeg installed, you can usepipto installnightcore(althoughpipxis recommended when only installing the CLI)pipinstallnightcoreBuilding from sourcenightcoreis built usingPoetry.$gitclonehttps://github.com/SeparateRecords/nightcore
$poetryinstall
$poetrybuildCLI Usagenightcoreis predictable and ensures there is no unexpected behaviour. As nightcore relies on FFmpeg under the hood, any format supported by FFmpeg is supported by the CLI.Speed/pitchSpeeding up a track is super easy. By default, it will increase the pitch by 1 tone.$nightcoremusic.mp3>out.mp3You can manually set the speed increase by passing a number after the file. Without specifying a type, the increase will be in semitones.$nightcoremusic.mp3+3>out.mp3TypesYou can change the type of speed increase by providing it after the number. At the moment, nightcore can take any ofsemitones,tones,octavesorpercent.$nightcoremusic.mp3+3tones>out.mp3When using percentages,100 percentmeans no change,150 percentis 1.5x speed,80 percentis 0.8x speed, etc.$nightcoremusic.mp3150percent>out.mp3Format & CodecIf file's format cannot be inferred from its extension, you can specify it manually with--format(-f).$nightcore--formatoggbadly_named_file>out.mp3The codec can be manually set using--codec(-c).OutputIf the output cannot be redirected, you can specify an output file with--output(-o). The format will be guessed from the extension.$nightcoremusic.mp3--outputout.mp3To manually set the output format (useful if redirecting), use--output-format(-x).$nightcoremusic.mp3--output-formatogg>music_nc.oggIf this option is not provided, the output format will be guessed in this order, defaulting to MP3 if all fail:Output option file extension (--output example.wav)Explicit input file type (--format ogg)Input file extension (music.ogg)EQTo compensate for a pitch increase, the output track will have a default +2db bass boost and -1db treble reduction applied.To disable this, pass in--no-eq. Note that if the speed is decreased, there will be no automatic EQ.$nightcoremusic.mp3--no-eq>out.mp3API UsageThe nightcore API is built usingpydub, a high level audio processing library. It's worth reading a bit of its documentation (or at least the section on exporting), but you'll get by with only having read the examples below.The API itself performs no equalization, unlike the CLI - seenightcore/cli.pyfor the implementation (search "parameters").As the wordnightcoreis long, it's recommended to import the module asnc.QuickstartYou can use any ofOctaves,Tones,Semitones, orPercentto change speed. These are all subclasses of the baseRelativeChangeclass.Using the @ operator with one of the above classes is the most convenient way to nightcore a path-like object orAudioSegment.importnightcoreasncnc_audio="tests/test.mp3"@nc.Tones(1)nc_audio.export("tests/test_nc.mp3")Advanced Usagenightcore(audio_or_path,amount, **kwargs) ->AudioSegmentThe @ operator is shorthand for thenightcorefunction. The function only needs to be called manually if:You need to provide additional keyword arguments toAudioSegment.from_fileThe operator is less readable in contextYou need to use a functionThere is also an equivalent async function in its own namespace (nightcore.aio).importnightcoreasnc# Additional keyword args are passed to AudioSegment.from_fileaudio=nc.nightcore("/tmp/badly_named_audio",nc.Semitones(2),format="ogg")ContributingContributions, feedback, and feature requests are all welcome and greatly appreciated, no matter how small.LicenseThis project is licensed under the MIT license.