Code Monkey home page Code Monkey logo

Comments (6)

bastibe avatar bastibe commented on July 26, 2024 1

You are using SoundDevice. This issue board is about SoundCard. These libraries are not the same.

from soundcard.

gonzalocasas avatar gonzalocasas commented on July 26, 2024

@mbatt which OS are you using? I use soundcard with mutiprocessing and works very well, nothing special in the setup thou, it's just regular multiprocessing.

from soundcard.

mbatt avatar mbatt commented on July 26, 2024

I use windows 10, finally I was able to send tones to differents devices (outputs) of my device in a separate python processes, but I faced a new weird issue.
when I send a tone of 1khz , the frequency is doubled.
I use spectralissime to view the signal it's 2khz.

from soundcard.

bastibe avatar bastibe commented on July 26, 2024

Did you set the samplerate? Could you show us a complete code example of what you were trying to do?

from soundcard.

mbatt avatar mbatt commented on July 26, 2024

Here is the code
mport sounddevice as sd
import soundfile as sf
import numpy as np
from audio_constants import *
from wasapi_device_index import *

""" create a numpy array from a .wav file"""
def wave2numpy(file):
data,fs = sf.read(file, dtype = 'float32')
return data

def open_output_stream(index):
out_stream = sd.OutputStream( device=index, dtype="float32",channels = 2 )
out_stream.start()
return out_stream

def play_audio_on_channel(audio_data, stream_object):
stream_object.write(audio_data)

"""here i call the function"""
wasapi_exclusive = sd.WasapiSettings(exclusive=True)
play_audio_on_channel(wave2numpy("Tone_750Hz_44100_600s.wav"),open_output_stream(30))

This is my device querry output:
['28', 'FCA1616', 'Line', '7/8', '(Behringer', 'FCA1616', 'WDM),', 'Windows', 'WASAPI', '(0', 'in,', '2', 'out)']
['29', 'FCA1616', 'Line', '1/2', '(Behringer', 'FCA1616', 'WDM),', 'Windows', 'WASAPI', '(0', 'in,', '2', 'out)']
['30', 'FCA1616', 'Line', '3/4', '(Behringer', 'FCA1616', 'WDM),', 'Windows', 'WASAPI', '(0', 'in,', '2', 'out)']
['32', 'FCA1616', 'Line', '5/6', '(Behringer', 'FCA1616', 'WDM),', 'Windows', 'WASAPI', '(0', 'in,', '2', 'out)']

from soundcard.

mbatt avatar mbatt commented on July 26, 2024

In the previous code I stream out a 750 Hz tone but it is played as a 1500Hz tone
when I use the play function I get the right frequency

def play_tone(file,channel,loop):
data,fs = sf.read(file,dtype = 'float32')
sd.play(data,fs,loop=loop, blocking = False, device=channel,never_drop_input=None)
status = sd.wait()
sd.stop()

play_tone("Tone_440Hz_44100_600s.wav", 30,False)

from soundcard.

Related Issues (20)

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.