GithubHelp home page GithubHelp logo

sndfile's Introduction

sndfile

Work in progress simple CFFI wrapper around the C libsndfile API.

Currently only implements a simple interface for reading frames from supported audio files into Python's array.array.

Example

A simple example that loads an audio file, prints some statistics, and dumps out all the frames as 32bit integers.

SAMPLES = pathlib.Path("my-audio-sample-dir")

with sndfile.open(SAMPLES / "my-sample.flac", "r") as sample:
    print("frames: {}".format(sample.frames))
    print("format: major={0[0]}, minor={0[1]}".format(sample.format))
    print("samplerate: {}".format(sample.samplerate))
    print("channels: {}".format(sample.channels))
    print("sections: {}".format(sample.sections))

    print(sample.read_frames("l"))

sndfile's People

Contributors

vodik avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

vodik

sndfile's Issues

installation of snd file via pip3 fails : Building wheel for sndfile (setup.py) ... error fatal error: sndfile.h: No such file or directory #include <sndfile.h>

installation of snd file via pip3 fails:

(base) marco@pc:~/Resemblyzer$ pip3 install sndfile
Collecting sndfile
  Using cached https://files.pythonhosted.org/packages/db/ce   
/797cacd78490aa9de2e0e119491079d380e2fbbd7a1c5057c9fb2120a643/sndfile-0.2.0.tar.gz
Requirement already satisfied: cffi>=1.0.0 in /home/marco/anaconda3/lib/python3.7/site-packages 
 (from sndfile) (1.12.3)
Requirement already satisfied: pycparser in /home/marco/anaconda3/lib/python3.7/site-packages  
 (from cffi>=1.0.0->sndfile) (2.19)
Building wheels for collected packages: sndfile
  Building wheel for sndfile (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/marco/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; 
   sys.argv[0] = '"'"'/tmp/pip-install-7w_p8_7r/sndfile/setup.py'"'"'; __file__='"'"'/tmp/pip-install-  
   7w_p8_7r/sndfile/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"',  
   open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, 
   '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-n2k5xwj9 --python-tag cp37
       cwd: /tmp/pip-install-7w_p8_7r/sndfile/
Complete output (23 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.7
  creating build/lib.linux-x86_64-3.7/sndfile
  copying sndfile/__init__.py -> build/lib.linux-x86_64-3.7/sndfile
  copying sndfile/vio.py -> build/lib.linux-x86_64-3.7/sndfile
  copying sndfile/build.py -> build/lib.linux-x86_64-3.7/sndfile
  copying sndfile/formats.py -> build/lib.linux-x86_64-3.7/sndfile
  copying sndfile/io.py -> build/lib.linux-x86_64-3.7/sndfile
  running build_ext
  generating cffi module 'build/temp.linux-x86_64-3.7/sndfile._sndfile.c'
  creating build/temp.linux-x86_64-3.7
  building 'sndfile._sndfile' extension
  creating build/temp.linux-x86_64-3.7/build
  creating build/temp.linux-x86_64-3.7/build/temp.linux-x86_64-3.7
  gcc -pthread -B /home/marco/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare 
  -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/marco/anaconda3/include
  /python3.7m -c build/temp.linux-x86_64-3.7/sndfile._sndfile.c -o build/temp.linux-x86_64-3.7/build
  /temp.linux-x86_64-3.7/sndfile._sndfile.o
  build/temp.linux-x86_64-3.7/sndfile._sndfile.c:494:10: fatal error: sndfile.h: No such file or 
directory
   #include <sndfile.h>
            ^~~~~~~~~~~
  compilation terminated.
  error: command 'gcc' failed with exit status 1
  ----------------------------------------
 ERROR: Failed building wheel for sndfile
  Running setup.py clean for sndfile
Failed to build sndfile
Installing collected packages: sndfile
  Running setup.py install for sndfile ... error
    ERROR: Command errored out with exit status 1:
     command: /home/marco/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; 
sys.argv[0] = '"'"'/tmp/pip-install-7w_p8_7r/sndfile/setup.py'"'"'; __file__='"'"'/tmp/pip-install- 
7w_p8_7r/sndfile/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', 
open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, 
'"'"'exec'"'"'))' install --record /tmp/pip-record-67675cxl/install-record.txt --single-version-externally-
managed --compile
         cwd: /tmp/pip-install-7w_p8_7r/sndfile/
    Complete output (23 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.7
    creating build/lib.linux-x86_64-3.7/sndfile
    copying sndfile/__init__.py -> build/lib.linux-x86_64-3.7/sndfile
    copying sndfile/vio.py -> build/lib.linux-x86_64-3.7/sndfile
    copying sndfile/build.py -> build/lib.linux-x86_64-3.7/sndfile
    copying sndfile/formats.py -> build/lib.linux-x86_64-3.7/sndfile
    copying sndfile/io.py -> build/lib.linux-x86_64-3.7/sndfile
    running build_ext
    generating cffi module 'build/temp.linux-x86_64-3.7/sndfile._sndfile.c'
    creating build/temp.linux-x86_64-3.7
    building 'sndfile._sndfile' extension
   creating build/temp.linux-x86_64-3.7/build
    creating build/temp.linux-x86_64-3.7/build/temp.linux-x86_64-3.7
    gcc -pthread -B /home/marco/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare 
-DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/marco/anaconda3/include
/python3.7m -c build/temp.linux-x86_64-3.7/sndfile._sndfile.c -o build/temp.linux-x86_64-3.7/build
/temp.linux-x86_64-3.7/sndfile._sndfile.o
    build/temp.linux-x86_64-3.7/sndfile._sndfile.c:494:10: fatal error: sndfile.h: No such file or 
directory
     #include <sndfile.h>
               ^~~~~~~~~~~
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/marco/anaconda3/bin/python -u -c 
'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-7w_p8_7r/sndfile/setup.py'"'"'; 
__file__='"'"'/tmp/pip-install-7w_p8_7r/sndfile/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', 
open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, 
'"'"'exec'"'"'))' install --record /tmp/pip-record-67675cxl/install-record.txt --single-version-externally-
managed --compile Check the logs for full command output.
  • Operating System: Ubuntu 18.04.02 Server Edition
  • gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
  • pip3 -V
    pip 19.2.3 from /home/marco/anaconda3/lib/python3.7/site-packages/pip (python 3.7)

Looking forward to your kind help.
Marco

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.