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

macbook pro intel ventura 13.3.1 audio issue #5

Open
tedx opened this issue Mar 24, 2024 · 11 comments
Open

macbook pro intel ventura 13.3.1 audio issue #5

tedx opened this issue Mar 24, 2024 · 11 comments

Comments

@tedx
Copy link

tedx commented Mar 24, 2024

I'm trying to use tg-timer but am not getting any indication on the GUI that the ticks are being heard. I've tried both a usb watch timergrapher device I bought on aliexpress and the internal mic. I've looked at the sound system setting and played with the input volume but that hasn't made any difference. Any suggestions? Has anyone gotten this to work on an macbook pro Intel running ventura 13.3.1?

@tedx
Copy link
Author

tedx commented Mar 24, 2024

I do see on the systems setting GUI that sound is coming from the usb device.

@xyzzy42
Copy link
Owner

xyzzy42 commented Mar 26, 2024

I don't know about that MacOS version. My macbook is too old to run it. But it should work.
Have you checked what audio device is selected in the audio setup dialog? Then check the peak meter in the signal dialog and see if there is any sound being received at all.

What version tg did you build are you using and what version of portaudio did you build it with?

@tedx
Copy link
Author

tedx commented Mar 26, 2024 via email

@tedx
Copy link
Author

tedx commented Mar 26, 2024

I don't think I'm getting any sound :( I wrote a simple python script to record from the built in mic:

chunk = 1024  # Record in chunks of 1024 samples
sample_format = pyaudio.paInt16  # 16 bits per sample
channels = 1
fs = 44100  # Record at 44100 samples per second
seconds = 10
filename = "output.wav"

p = pyaudio.PyAudio()  # Create an interface to PortAudio

print('Recording')

stream = p.open(format=sample_format,
                channels=channels,
                rate=fs,
                frames_per_buffer=chunk,
                input=True)

frames = []  # Initialize array to store frames

# Store data in chunks for 3 seconds
for i in range(0, int(fs / chunk * seconds)):
    print(i)
    data = stream.read(chunk)
    frames.append(data)

# Stop and close the stream 
stream.stop_stream()
stream.close()
# Terminate the PortAudio interface
p.terminate()

print('Finished recording')

# Save the recorded data as a WAV file
wf = wave.open(filename, 'wb')
wf.setnchannels(channels)
wf.setsampwidth(p.get_sample_size(sample_format))
wf.setframerate(fs)
wf.writeframes(b''.join(frames))
wf.close()

and one to play the wav:

import pyaudio
import wave

filename = 'output.wav'

# Set chunk size of 1024 samples per data frame
chunk = 1024  

# Open the sound file 
wf = wave.open(filename, 'rb')

# Create an interface to PortAudio
p = pyaudio.PyAudio()

# Open a .Stream object to write the WAV file to
# 'output = True' indicates that the sound will be played rather than recorded
stream = p.open(format = p.get_format_from_width(wf.getsampwidth()),
                channels = wf.getnchannels(),
                rate = wf.getframerate(),
                output = True)

# Read data in chunks
data = wf.readframes(chunk)

i = 0
# Play the sound by writing the audio data to the stream
while data != '':
    print(i)
    i = i + 1
    stream.write(data)
    data = wf.readframes(chunk)

# Close and terminate the stream
stream.close()
p.terminate()

but I don't hear anything.

@xyzzy42
Copy link
Owner

xyzzy42 commented Mar 26, 2024

Signal dialog, like Audio Setup dialog, is one of the options in the main menu. Did you install --HEAD version of tg-timer using brew? Or build yourself from a source clone from github? Audio setup dialog should show multiple devices, it could be the recording is from the wrong device.

Maybe there might be issues with portaudio on Ventura. You could try Audacity, and see if the wav file you recorded is really empty, or if maybe the sound output has an issue. And Audacity also uses portaudio, it should be easily to see if it can record or not in Audacity.

@tedx
Copy link
Author

tedx commented Mar 26, 2024

I built from source and see the audio setup dialog but not a 'signal' dialog. Audacity works.

@xyzzy42
Copy link
Owner

xyzzy42 commented Mar 26, 2024

What git version did you build?

There is an issue on portaudio for Ventura, PortAudio/portaudio#771 but it looks like the result there is errors trying to use the audio device, not no audio. Since audacity works, it seems like portaudio should be possible to use. It still wonder if correct audio device selection is an issue. You haven't yet said you checked what devices are visible in the audio setup dialog.

@tedx
Copy link
Author

tedx commented Mar 27, 2024

Is this what you want to see?
git log

commit 18df6de343f1e195bb9cbbe3a40c023d8b3ef277 (HEAD -> master, origin/master, origin/HEAD)
Author: Trent Piepho <[email protected]>
Date:   Tue Oct 11 23:42:34 2022 -0700

    Update spec to work with new version of rpkg
    
    Lack of auto_pack is the problem.
    
    https://docs.pagure.org/copr.copr/rpkg_util_2_vs_3.html#rpkg-util-v3

Yes I've select the device on the audio dialog.

@xyzzy42
Copy link
Owner

xyzzy42 commented Mar 27, 2024

Yes, that's what I was looking for. Just the commit 18df6de is sufficient, everything else is knowable from that. That's an older branch, I don't think the signal dialog was implement yet in that one. Try checking out new-stuff. git checkout new-stuff That branch has the Signal dialog. Should be able to tell if there really is NO audio or it's just too quiet to hear.

You might also need Python installed for that feature to be enabled. The signal meter does't use it, but the spectrograms use that, and they are in the same dialog. Looks like you know Python pretty well and already have it installed. Last I checked, numpy and scipy were available on brew, but matplotlib and libtfr needed to be installed with pip. Those are the packages used.

There have been several problems with app permissions for audio with PortAudio on MacOS. But if you're able to see a list of audio devices, select one, and then run without any errors (any errors in the terminal?) then that's not like any of those previous problems. It always failed before getting that far.

Makes me wonder if there is some kind of mixer problem, and the gain is just not set high enough to hear anything by default.

Another test to try, is record from Audacity, which apparently does work and gets audible sound, and at the same time it's running, try tg-timer. If Audacity is doing something to unmute or adjust the gain, maybe it will apply to anything using the device.

@tedx
Copy link
Author

tedx commented Mar 27, 2024

Got new-stuff, rebuilt and started signal dialog and see nothing. With audacity I could hear and record the watch through the built in mic. Also I'd bought a TGBC usb watch mic from china and plugged it in , ran audacity selecting it as input and recorded the watch just fine. In tg-timer I select the usb device from the dialog drop down but still nothing on the signal dialog. I did try as you suggested running tg-timer while running audacity but that didn't make any difference. tg-timer just isn't getting any input sound. FWIW I used the pyaudio example record and playback code to write a wav file and play it back but that doesn't work either. I opened an issue related to this with pyaudio but no one has responded yet. Thanks for looking at this I do wish it worked. I can use the android watch timer app and that works fine but it doesn't give as much info as tg-timer would :(

@xyzzy42
Copy link
Owner

xyzzy42 commented Mar 30, 2024

I'd report it to the PortAudio github page. Since both tg and pyaudio use portaudio, the problem is likely there.

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

No branches or pull requests

2 participants