portaudio | PortAudio module for godot | Game Engine library
kandi X-RAY | portaudio Summary
kandi X-RAY | portaudio Summary
portaudio === module for godot.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of portaudio
portaudio Key Features
portaudio Examples and Code Snippets
Community Discussions
Trending Discussions on portaudio
QUESTION
I'm trying to implement a very simple API for audio playback using portaudio
. I have minimal amount of code needed to play the audio file but I am not getting any errors and/or audio output.
Here is the code,
...ANSWER
Answered 2022-Apr-07 at 23:24You've got two flaws that I can see.
One is using what looks like a class method as the callback to PulseAudio. Since PA is a C API, it expects a C function pointer here. It won't call that function with the this
pointer set, so you can't have a class method here. But maybe AudioStream::Callback
is static
? That will work.
Two is that you need to consider that the callback is called in another thread. The compiler does not take that into account when it optimizes the code. As far as it knows, there is nothing in your empty while loop that could possibly change the value of file->count
.
Once you call the debug function, it brings in enough code, some probably in libraries that are already compiled, that the compiler can't be sure nothing has modified file->count
. Maybe SH_LOG_DEBUG()
calls prinf()
and then printf()
calls AudioStream::Load()
? Of course it doesn't, but if the compiler doesn't see the code of printf()
because it's already in a library, and your AudioStream
object is global, then it's possible. So it actually works like you want.
But even when it works, it's really bad. Because the thread is sitting there busy waiting for the count to stop, hogging the/a CPU. It should block and sleep, then get notified when the playback finishes.
If you want to pass information between threads in a way that works, and also block instead of busy waiting too, look into the C++ concurrency support library. The C++20 std::latch
and std::barrier
would work well here. Or use a C++11 std::condition_variable
.
QUESTION
I am currently working on a patch that should make portaudio work for iOS. For now I successfully applied portaudio member Hans Petter's patch for iOS usage
https://www.dropbox.com/s/6hf9bjqpa6b6uv3/0001-Add-basic-support-for-iOS-to-portaudio.patch?dl=0
and at least I call tell that the audio process does work, however, it is currently stuck at 1024 samples. When I try decreasing it to lower values the callback function terminates immediately. When using 48 kHz it terminates without any warning or error message but when using 44.1 kHz it crashes with t the following error:
Assertion failed: (*streamCallbackResult == paContinue || *streamCallbackResult == paComplete || *streamCallbackResult == paAbort), function PaUtil_EndBufferProcessing, file pa_process.c, line 1499. dyld4 config: DYLD_LIBRARY_PATH=/usr/lib/system/introspection DYLD_IMAGE_SUFFIX=_debug DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib
referring to line 1497 in pa_process.c -->
assert( *streamCallbackResult == paContinue || *streamCallbackResult == paComplete || streamCallbackResult == paAbort ); / don't forget to pass in a valid callback result value */
I'd like to get as low as possible in terms of buffer size (ideally 128 or even 64), however, since I am not familiar with audio on iOS am now seeking for first inspirational comments. On OSX, Win or Linux this problem does not exist. Maybe iOS expects special low-latency flags ?
...ANSWER
Answered 2022-Mar-16 at 20:37Meantime I figured that iOS is able to handle audio frame sizes < 1024 (down to 128 and possibly less) and that the portaudio patch requires additional modifications and calls in order to make it work. Once completed I will provide the patch and further details here.
QUESTION
C:\Users\mudit\AppData\Local\Programs\Python\Python310\include\pyconfig.h(117): warning C4005: 'MS_WIN64': macro redefinition
src/_portaudiomodule.c: note: see previous definition of 'MS_WIN64'
src/_portaudiomodule.c(29): fatal error C1083: Cannot open include file: 'portaudio.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
----------------------------------------
ERROR: Failed building wheel for pyaudio
...ANSWER
Answered 2022-Feb-21 at 09:43Actually pyaudio cant be installed now as python has ended its support but if you need py audio donwload from hereenter link description here
choose the correct version of pyaudio or simply watch this video on youtube enter link description here
QUESTION
When I declare buffer
as float buffer[FRAMES_PER_BUFFER][2]
, I get a nice sound out of PortAudio's Pa_WriteStream
. When I declare buffer as a float **
and then dynamically allocate (and zero out) a block of memory for it, I get no sound or popping (be careful if you try this on your computer).
As far as I can tell the structure of block pointed to by buffer
in each case is identical, but the memory location is different (stack vs heap). This can be seen by the output of the cout
statements at the end of the attached example.
How can I dynamically allocate buffer
? My application will not know FRAMES_BER_BUFFER or the constant 2 (could be 3 or 4) at compile time.
I'm running this code on Mac with PortAudio 19.5.0 and compiling with gnu (tried various versions).
...ANSWER
Answered 2022-Feb-15 at 20:26How do you dynamically allocate a buffer for PortAudio Pa_WriteStream in C++?
float buffer[FRAMES_PER_BUFFER][2]
Just:
QUESTION
i am new to linux and i am setting up my code (in code i trying to take audio input from user and changing it to text). ran into problem while installing pyaudio .when i try to install pyaudio(by pipwin install pyaudio
) following showed
ANSWER
Answered 2022-Feb-02 at 18:22Like it says, you need the portaudio
library installed. Assuming you are running Ubuntu, something like this should work:
QUESTION
ANSWER
Answered 2021-Dec-17 at 12:11From the error message I believe the sound file you've used here has a sampling rate of 32000 Hz, but you have another sound in your project sampled at 48000 Hz. Switching between sample rates is called resampling but resampling takes time. PsychoPy is designed to provide low-latency playback of sounds but to do this it will not perform any resampling for you. As a result, you should convert all your sounds to use the same sampling rate before the study runs using some audio software
QUESTION
I am trying to build a portable sound synthesiser using the cross-platform library portaudio. The library has it's own CMake file to be built with. I think I have managed to build it as part of my project (build finishes with exit code 0) but I can't figure how to actually use it's imports. Any #include I try to use results in cannot open source file
.
This is my project's CMake file:
...ANSWER
Answered 2021-Nov-13 at 18:13I had to also link the executable with the library with
target_link_libraries(sound-synth PortAudio)
.
Then on windows I had the problem that the .dll was placed in a separate folder from the .exe. So I just added a copy file command and that fixed it.
QUESTION
I am using pyaudio to record sounds on my Mac BigSur 11.6 (20G165). Specifically, I'm redirecting sound from an application to the input using BlackHole, which works fine.
It usually works fine but, sometimes, I get this error in the Terminal:
||PaMacCore (AUHAL)|| Error on line 2500: err='-10863', msg=Audio Unit: cannot do in current context
Any idea why or how I could prevent it from happening (like, waiting until PaMacCore is ready to record again or something)?
I already tried reinstalling but it doesn't help
...ANSWER
Answered 2021-Nov-03 at 16:29Apparently the problem were mismatched bitrates in BlackHole's aggregated output device. I was aggregating Blackhole's output (44,1kHz) and the Mac Speakers (48kHz). This did not cause any consistent bad behaviour but sometimes led to these errors.
QUESTION
I'm trying to record and play some sound with Portaudio, the objective is to create a simple voip app, so i'm trying to transfer recorded data from the first client to a second client. The problem is when it comes to play the recorded sound, i either have no sound played, of a very buzzy sound, let me explain :
here are my record and play callback functions :
...ANSWER
Answered 2021-Oct-15 at 13:46I can't seem to find what's wrong, but I messed up something, ended up cutting the example again and it worked.
QUESTION
I'm trying to encode with Opus some data recorded via PortAudio, so whenever I try to encode data, the written data is lost because the unsigned char vector ends up being empty for every iteration of the vector, the original data is recorded from PortAudio
here are my structures :
...ANSWER
Answered 2021-Oct-14 at 11:30It looks like the problem is that you're keeping two sizes. You're mixing C and C++ style, which probably explains the std::vector *
. But more importantly, std::vector
stores its own size, yet you also store a seprate size. And it looks like they don't agree.
The fix is easy. Don't store that .size
in AudioEnc and AudioData. Instead, call .resize
on the vectors to remember the size returned from Opus. This will discard the unused entries.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install portaudio
Download the zip (https://github.com/sebastian-heinz/portaudio/archive/master.zip) and extract it into the godot/modules-folder. Since it is missing the portaudio source, it has to be manually added. Get it from http://www.portaudio.com/archives/pa_stable_v190600_20161030.tgz and paste it into the empty portaudio folder. (./portaudio/portaudio/) <img src="/doc/port_audio_example.png" width="400">
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page