software to generate pulsed tones ? - Page 1
Forum section: electronics / general

author: jmelson
author_rank: Super Contributor
timestamp: June 07, 2019, 09:12:23 pm
content: Didn't know where to post this, so ... I'm looking for a program that can generate pulsed tones through a PC sound card.I've found sox, which looks like it might be able to do what I want, but it is a pretty complex program.What I'm trying to do is generate pulsed ultrasound, and somebody is going to measure the effects of pulse duration and rep. rate on chemistry.They are looking at 30 KHz sine waves, so a sound card running at 96KHz sample rate should do fine. But, we need to generate a sequence of pulses, maybe tens to hundreds of ms duration, repeated so many times. These could be generated as a bunch of sound files that are then played in sequence during the experiment, or just generated and played live.It looks like the sox function trim can do the pulsing, but I'm not too clear on the syntax. The man page is pretty terse on the trim function.Does anyone have some experience using sox, or any other program for generating pulsed sine tones?Thanks much,Jon

author: Ampera
author_rank: Super Contributor
timestamp: June 07, 2019, 09:27:03 pm
content: Audacity. I've now saved the 95% of everyone else who would say the same thing from doing so.

author: jmelson
author_rank: Super Contributor
timestamp: June 07, 2019, 10:40:48 pm
content: Quote from: Ampera on June 07, 2019, 09:27:03 pmOK, I've used audacity, but don't really see how one would create several hundred sound files with different tone/silence spacing.A command-line tool might actually be easier, I could write a program that would write a script with varying parameters.If there's a way to do this in audacity, I don't know of it. All I've seen is the GUI interface to it.Thanks,Jon

author: SparkyFX
author_rank: Frequent Contributor
timestamp: June 07, 2019, 11:24:35 pm
content: No experience, but this sounds suitable:http://manpages.ubuntu.com/manpages/bionic/man1/tones.1.htmlPart of the siggen package.For quick and dirty like this, i suggest concatenating the command lines in your spreadsheet application of choice, copy to a bash script and so on.

author: NiHaoMike
author_rank: Super Contributor
timestamp: June 07, 2019, 11:57:44 pm
content: GNUradio?

author: Ian.M
author_rank: Super Contributor
timestamp: June 08, 2019, 12:33:51 am
content: Using a high end PC soundcard for this is likely to be nothing but trouble. Why not use an Arduino controlling a DDS module to generate the actual tone pulses? The PC then only has to give it serial commands for amplitude, frequency, duration, inter-pulse gap etc. and once set up, the Arduino runs the sequence autonomously.

author: soldar
author_rank: Super Contributor
timestamp: June 08, 2019, 06:43:01 am
content: Several thoughts. Besides Audacity I have Cool Edit which is a very simple older program and will do it.What are you going to use as a speaker or transducer? Because at 30 KHZ a regular speaker won't do.At 30 KHZ possibly the audio card won't do either.At 30 KHZ you need a codec that will go up to a sufficiently high sampling rate and not all do. I seem to remember most top out at 48 KHZ.You want to generate tens or hundreds of files? That's a lot of work,Why not just generate the tone directly with a 555 or other hardware solution where you can set the duration of the tone and the duration of the silence? It would be really simple to do and requires no PC.

author: voltsandjolts
author_rank: Unknown
timestamp: June 08, 2019, 08:49:04 am
content: My choice would be using GNU Octave (similar to MATLAB, but free open source) running a script to generate the required tones.They can be saved as CSV format for transfer to an arb gen, such as the SDG2042X (I own one, nice tool).Example script for tone generation in Octave:https://www.eevblog.com/forum/testgear/siglent-sdg1000-arbitrary-csv-file-format/msg1973726/#msg1973726

author: Electro Detective
author_rank: Super Contributor
timestamp: June 08, 2019, 09:36:44 am
content: Quote from: soldar on June 08, 2019, 06:43:01 amAre PC sound cards band limited somehow that can be (simply) bypassed? or is it a software/firmware thing?IIRC audio programs like Soundforge had/have? the features OP requiresCool Edit is hard to beat as an all rounder

author: magic
author_rank: Super Contributor
timestamp: June 08, 2019, 05:02:27 pm
content: If timing between pulses is important, I recommend generating a single file with the entire sequence because it's easier than trying to accurately time playback of multiple tiny files.This appends 0.1 second of 1kHz tone to out_file, 96kHz, 16bit, stereo.Code:sox -n -t raw -e signed -r 96k -b 16 -c 2 - synth 0.1 sine 1k >> out_fileThis adds 0.05 second of silence.Code:sox -n -t raw -e signed -r 96k -b 16 -c 2 - trim 0 0.05 >> out_fileThis converts the sequence of raw samples to WAV.Code:sox -t raw -e signed -r 96k -b 16 -c 2 out_file out_file.wav

author: jmelson
author_rank: Super Contributor
timestamp: June 12, 2019, 07:10:05 pm
content: Quote from: magic on June 08, 2019, 05:02:27 pmFantastic, thanks! This works, just a little cumbersome to concatenate a bunch of beeps and spaces, but it certainly works as a quick test to make sure this will work. Still have to see if we can actually get 30 KHz sine wave out of a sound card, but this quick and dirty test at 1 KHz works.Thanks again,Jon

author: magic
author_rank: Super Contributor
timestamp: June 13, 2019, 10:24:23 am
content: I'm not sure if it's possible to program sox to generate multiple tones in one run. This at least worksYou should be able to get 30kHz. I generated up to 80kHz with three different 192kHz soundcards.

author: ogden
author_rank: Super Contributor
timestamp: June 13, 2019, 10:39:35 am
content: Quote from: jmelson on June 07, 2019, 10:40:48 pmWAV RIFF header is quite simple, you can write audio files directly from your script/program.https://docs.python.org/3/library/wave.html

author: mark03
author_rank: Frequent Contributor
timestamp: June 14, 2019, 04:02:48 am
content: The easiest way to do this with full flexibility is either MATLAB or Python, whichever you happen to know better. In MATLAB it is literally just creating a vector then calling the function that saves it as a WAV file. (You can play the sound through the sound card from MATLAB too.) Due to inertia I have not tried this in Python with numpy/scipy but I assume it's possible.Just because the sound card advertises 96 kHz does not mean it will output up to 40-something kHz. Strange but true. I was doing something similar for an ultrasound demo: Take any MP3 file, frequency-translate it by 15 or 20 kHz, play the sound (inaudible, at least to adults), then tune it in using a simple receiver intended for listening to bats. Maybe it's because I was using cheap hardware, but I had a hard time finding a USB sound dongle that would go to 30 kHz. Maybe they were internally resampling to 48k?I had good results using this transducer, only available in Europe for some reason;https://www.kemo-electronic.de/en/Car/Speaker/L010-Piezo-Loudspeaker.phpI bet there are tweeters that would work too.

author: FrankBuss
author_rank: Unknown
timestamp: June 14, 2019, 05:29:23 am
content: I would use Python for it. Here is an example:https://gist.github.com/FrankBuss/3c2f0d1eaf289ef9f659139b96e7a459Tested on Linux, but should work on Windows and Mac as well with Python 3. You can configure the sample rate and frequency in the file, and then use command line arguments for the lengths. E.g. calling it like this:Code:python3 test.py 0.1 0.9 10Plays 10 beeps of 0.1 second, with 0.9 second pause between each beep.With Qt for Python you could even easily add a nice GUI for it with a few lines of code:https://blog.qt.io/blog/2018/05/04/hello-qt-for-python/

author: jmelson
author_rank: Super Contributor
timestamp: June 14, 2019, 06:57:04 pm
content: Quote from: Electro Detective on June 08, 2019, 09:36:44 amMaybe! I got a scope hooked up to the output, and what I see is that sox-generated files work up to 20 KHz, but then the fundamental will not increase above that. So, if I tell it to generate a 30Khz signal, I get 17.5 KHz At this point, I'm not sure if this is that sox won't generate a higher frequency, or that the sound card is doing something to it like aliasing. Changing the sample rate has no effect, i tried 96k and 128k, I get the same frequency out.Still investigating.Jon

author: jmelson
author_rank: Super Contributor
timestamp: June 14, 2019, 07:39:51 pm
content: Quote from: Electro Detective on June 08, 2019, 09:36:44 amYes, it seems so. sox does something funny when you enter synth sine frequencies over 20k, but what I did was use sox to make a raw file at one sample rate, and then change the sample rate to increase the frequency. So, I can generate a 10khz sine, and then play it back at twice the sample rate, and I get 20KHz.I can go up to about 11 KHz doubled and get something out, but 11.5 doubled is just about the level of the noise. So, it seems there is a sharp cutoff filter that ALWAYS cuts off below 22 KHz, no matter what the sample rate is set to. UGH! Maybe there's another sound card where the filter scales with the sample rate, otherwise, why even have an adjustable sample rate.If anybody has any idea, I'd love to hear them. Yes, of course, we could build a whole app and drive a DAC over USB or something, but we just wanted something quick and dirty first to test the idea.Jon

author: jmelson
author_rank: Super Contributor
timestamp: June 14, 2019, 08:07:47 pm
content: Quote from: mark03 on June 14, 2019, 04:02:48 amDid you find a sound card or USB dongle that would do over 30 KHz? I see there are some high-end audio ones that can go to 80 KHz with 192 ksamps/second data rate, but they are a tad pricey. (Some are over 1K, but there seem to be 2 that are about $190.)We have several arbitrary waveform generators here that could be used for quick initial tests, but they are somewhat complicated to program. The PC and sound card route is dead easy by comparison.Thanks,Jon

author: FrankBuss
author_rank: Unknown
timestamp: June 15, 2019, 02:17:16 am
content: Looks like my USB sound card has a low pass filter, so no frequency higher than 20 kHz can be generated.I tried another way, using the wavegen of my DSO-X3012A oscilloscope. It has the option to AM modulate the generated signal. A 30 kHz sine wave signal modulated with a 1 kHz square wave signal looks like this:Detail view:No programming etc. required, just clicking some buttons and turning some knobs. Many cheap dedicated arbitrary waveform generators have AM modulation capability as well.I can also control the wavegen on my scope with a Python script over network with SCPI commands. With this Python script:Code:#!/usr/bin/python3import socketimport times = socket.socket()host = "192.168.11.25"# 5025 port is without command line, port 5024 with command lineport = 5025s.connect((host, port))def cmd(c):s.send((":wgen:" + c + "\r\n").encode())# reset wavegen generator to defaults: 1 kHz sine wave, 0.5 Vpp amplitude, 0 V offsetcmd("rst")# set 5 Vpp amplitudecmd("volt 5")# enable wavegen generatorcmd("outp 1")# generate 100 pulses of 0.1 s with 0.9 s pausefor i in range(100):cmd("freq 30000")time.sleep(0.1)cmd("freq 0.1")time.sleep(0.9)# disable wavegen generatorcmd("outp 0")I get this output:I changed the frequency to the minimum allowed 0.1 Hz for "off" instead of setting the output voltage to 0, to avoid the relay clicking all the timeBut as you can see, it is not very accurate, the 0.1 s on period is sometimes a little bit longer or shorter. Maybe the SCPI interface is not that fast, or there are some delays introduced by the PC or ethernet network. But might be sufficient for first tests.I think the best solution would be an external DAC, controlled by a microcontroller. This would allow you to control it very accurately, and in realtime.

author: soldar
author_rank: Super Contributor
timestamp: June 15, 2019, 08:12:36 am
content: Again, this is trivial to do with a couple of 555s. Is there any reason to be doing it with a computer sound card? It is just not the right tool. And what transducer?If you must use something programmable how about Arduino or Raspberry?

author: magic
author_rank: Super Contributor
timestamp: June 15, 2019, 10:55:42 am
content: Sorry guys, I misunderstood sox options and thought that format switches need only to be applied to the output file, but they actually need to be applied to the input too (even if there is no input file, so -n) in order to setup the whole processing pipeline at 96kHz. I've never actually used sox to write files before, I used the bundled play command which synthesizes straight to the soundcard.Here's corrected version, tested at 30kHz with a scope. You can also validate generated WAV files by loading them into audacity or matlab and running FFT.Code:sox -e signed -r 96k -b 16 -c 2 -n -t raw - synth 0.1 sine 30k vol 0.9999 >> out_filesox -e signed -r 96k -b 16 -c 2 -n -t raw - trim 0 0.05 >> out_filesox -e signed -r 96k -b 16 -c 2 -t raw out_file out_file.wavI added "vol 0.9999" to silence warnings about signal being clipped, apparently peaks exceeded full scale by 0.01% due to numerical inaccuracy or some other bullshitQuote from: soldar on June 15, 2019, 08:12:36 amIt is a perfect tool for such jobs, unlike 555 which only generates square waves. That being said, I probably should get myself some real sig gen for higher bandwidth and better output protection, if nothing else.Quote from: FrankBuss on June 15, 2019, 02:17:16 amIt's called DDS and there are single-chip solutions if all you need is sine/square/sawtooth. You just program a few registers over SPI or something like that and it does the rest for you.Quote from: jmelson on June 14, 2019, 08:07:47 pmAny common motherboard-integrated "high definition audio" capable of 192kHz playback will do. Realtek, VIA, Creative, others.Cheap-ass USB dongles may be limited to 48kHz and Windows will gladly downsample higher resolution streams for you without warning.

author: GlennSprigg
author_rank: Super Contributor
timestamp: June 15, 2019, 11:23:32 am
content: I LOVE making Graphical (GUI) Front-Ends for control of underlying code !'SoX' certainly looks like the meat & the bones, to do what you want, and more...Don't know you expertise there (GUI), but I could throw some examples you way...

author: soldar
author_rank: Super Contributor
timestamp: June 15, 2019, 02:33:47 pm
content: Quote from: magic on June 15, 2019, 10:55:42 amI do not know what transducer you plan on using but I assume piezo-electric. A 30 KHz piezo transducer can be fed a square wave and will probably filter out most harmonics. I would not think using a square wave would make much difference if any. Even then, using a square signal followed by a passive low pass filter is easy to build.Designing a sine oscillator fixed at 30 KHz is trivial as well.My computer has no problem generating and storing files with 30 KHz tone sampled at 96K. What I do not have is a codec to compress it. My codec's highest sampling is 48K. So I have uncompressed 30 KHz samplez at 96K.I have not tried to see if my audio card will actually output 30 KHz because I would need to bring in the scope from the other room and that information would not be useful unless you have the same audio card.

author: NiHaoMike
author_rank: Super Contributor
timestamp: June 15, 2019, 02:38:42 pm
content: Quote from: soldar on June 15, 2019, 02:33:47 pmUse FLAC.

author: jmelson
author_rank: Super Contributor
timestamp: June 16, 2019, 01:17:27 am
content: Quote from: soldar on June 15, 2019, 08:12:36 amThe experiment may require that we run several hundred different and well-known trains of ultrasonic pulses, with different intensities, burst lengths and pauses between pulses. Then the test articles will be analyzed.For right now, we want something simple, later we may well use something like maybe a Beagle Bone, that I'm pretty familiar with (if it has a sound chip that can do it, great, otherwise run a DAC with the PRU units.)Jon

author: jmelson
author_rank: Super Contributor
timestamp: June 17, 2019, 08:44:15 pm
content: Quote from: magic on June 15, 2019, 10:55:42 amThanks, that fixed the creation of the sound file, so it now seems to generate the frequency specified, but my sound chipset still has the fixed cutoff frequency.Looking for a better sound card.Jon

author: magic
author_rank: Super Contributor
timestamp: June 17, 2019, 10:50:59 pm
content: What kind of soundcard is that? Really, any integrated crap made in this decade should work.

author: jmelson
author_rank: Super Contributor
timestamp: June 18, 2019, 08:09:18 pm
content: Quote from: magic on June 17, 2019, 10:50:59 pmThe ONE UNIT I've tried so far is an Intel Sunrise chip in a Dell Optiplex 7040. It clearly has a 22 KHz low-pass filter, as any signal above 20 KHz shows rapid decrease in amplitude, and 22 KHz is not detectable above the noise. I am going to try a couple different computers before going out and buying an "audiophile-grade" sound card.Jon

author: magic
author_rank: Super Contributor
timestamp: June 19, 2019, 09:31:28 am
content: So it's a brickwall filter so clearly digital because nobody would bother with analog these days.I'm surprised, your machine supposedly contains a Realtek ALC255 and I've never had such problems with Realtek chips, they just work up to 90% of Nyquist or so.I see no reason why the would suddenly add a 20kHz lowpass at high sample rates in their chips so I'm inclined to blame software.In particular, whatever software it is that takes audio streams from applications and mixes them into one stream to the DAC. Check Windows settings and any "Realtek Control Panel" or whatever, maybe there is a master sample rate switch somewhere. I haven't used Windows in years, though, so can't help more than that. Or see what "audiophiles" do to get bit-perfect playback of their 192kHz files on Windows.

author: soldar
author_rank: Super Contributor
timestamp: June 19, 2019, 10:51:35 am
content: If I remember my Nyquist correctly you need to have a low pass filter at theNyquist rateor you will havealiasing.

author: Nominal Animal
author_rank: Super Contributor
timestamp: June 19, 2019, 05:06:21 pm
content: Quote from: FrankBuss on June 14, 2019, 05:29:23 amOr even with thetkintermodule that is standard part of Python (works on all OSes). Runpython -m tkinterto test on your machine. It's not as nice as Qt, and might look a bit dated to users (older looking widgets), but might make installation easier for Windows users.I'd recommend putting the audio generator in a separate process (using themultiprocessingmodule), and control it via aqueueof tuples of(freqHz, duration). A very simple class can represent these, and serialize them to and from human-readable text files. I'd spec the format to allow later extension to e.g. linear or cubic frequency and envelope control, just in case (so one line per tone/space).If this was my research project, I'd play with graphics and ideas and a non-poweruservictimtest person, to see what kind of user interface would work best. One part of the user interface should show the currently playing sequence, perhaps using a horizontal bar with colors representing frequency? Another part should allow the user to load, edit, and save sequences. I'd even go as far as have a yet another part, where existing sequences can be combined (uh, sequentially), like playlists. It might take a few extra hours, but I've found that focusing on and getting feedback on the UI part is worth the effort in the long run.

author: jmelson
author_rank: Super Contributor
timestamp: June 19, 2019, 08:12:05 pm
content: Quote from: magic on June 19, 2019, 09:31:28 amThis is a Linux system, Ubuntu 17.10, and lspci oddly shows two audio devices :00:1f.3 Audio device: Intel Corporation Sunrise Point-H HD Audio (rev 31)and01:00.1 Audio device: NVIDIA Corporation GF108 High Definition Audio Controller (rev a1)The 2nd one is likely in my video card, and only works through the HDMI port, I'm guessing.Apparently, different versions of the same base model # can have a different motherboard, so the small form factor, mini-tower and full tower might be different.I saw that RealTek only on the 7040M model. The others list just 2-channel audio subsystem. Darn, wish I had the RealTek.Yes, I wouldn't be surprised if there is a setting or option that controls the filter. But, I have not found that, yet.Thanks,Jon

author: magic
author_rank: Super Contributor
timestamp: June 19, 2019, 10:17:03 pm
content: Quote from: jmelson on June 19, 2019, 08:12:05 pmOkay, now we are talking. CheckCode:$ cat /proc/asound/card0/pcm0p/sub0/hw_paramsaccess: RW_INTERLEAVEDformat: S32_LEsubformat: STDchannels: 2rate: 96000 (96000/1)period_size: 512buffer_size: 8192You will probably find out it runs at wrong sample rate.TryCode:aplay whatever-file.wav -D hw:0If you get "file busy" errors, figure out which process is using itCode:fuser /dev/snd/pcm*Most likely some PulseAudio or other such. Stop it or reconfigure it to run at 96k or more. It seems PA defaults to 44k but that can be changed with ease -some random instruction here.Quote from: jmelson on June 19, 2019, 08:12:05 pmHigh Definition Audio soundcard consists of a PCI part provided in the chipset and an external "codec" which contains actual DACs/ADCs. The latter is probably from Realtek or similar vendor. They all should do up to 192k these days with ease.If you are curiousCode:cat /proc/asound/card0/codec*The first line lists codec name, others will contain supported sample rates if you manage to find them in all that noise

author: Nominal Animal
author_rank: Super Contributor
timestamp: June 19, 2019, 10:45:29 pm
content: If you're not playing any sound, runningarecord -D hw:CARD=PCH,DEV=0 --dump-hw-paramsshould show the actual hardware capabilities. For example, on this laptop the output isCode:Recording WAVE 'stdin' : Unsigned 8 bit, Rate 8000 Hz, MonoHW Params of device "hw:CARD=PCH,DEV=0":--------------------ACCESS: MMAP_INTERLEAVED RW_INTERLEAVEDFORMAT: S16_LE S32_LESUBFORMAT: STDSAMPLE_BITS: [16 32]FRAME_BITS: [32 64]CHANNELS: 2RATE: [48000 96000]PERIOD_TIME: (166 170667)PERIOD_SIZE: [16 8192]PERIOD_BYTES: [128 65536]PERIODS: [2 32]BUFFER_TIME: (333 341334)BUFFER_SIZE: [32 16384]BUFFER_BYTES: [128 65536]TICK_TIME: ALL--------------------arecord: set_params:1233: Sample format not availableAvailable formats:- S16_LE- S32_LEso I can runaplay -D hw:CARD=PCH,DEV=0 --disable-resample --disable-channels --disable-format --disable-softvol -c 2 -f S16_LE -r 96000, and provide that commands standard input with little-endian 16-bit signed integers, interleaved, at 96 kHz sample rate. In Python, ifsis a sample between -1.0 and +1.0,struct.pack("<hh", int(32767.9 * s), int(32767.9 * s))will produce the four bytes one needs to write to write that sample to both left and right channels for that commands standard input.

author: jmelson
author_rank: Super Contributor
timestamp: June 19, 2019, 10:46:55 pm
content: Quote from: magic on June 19, 2019, 10:17:03 pm

author: jmelson
author_rank: Super Contributor
timestamp: June 19, 2019, 10:52:46 pm
content: OK, I get this from the arecord command you showed :arecord -D hw:CARD=PCH,DEV=0 --dump-hw-paramsRecording WAVE 'stdin' : Unsigned 8 bit, Rate 8000 Hz, MonoHW Params of device "hw:CARD=PCH,DEV=0":--------------------ACCESS: MMAP_INTERLEAVED RW_INTERLEAVEDFORMAT: S16_LE S32_LESUBFORMAT: STDSAMPLE_BITS: [16 32]FRAME_BITS: [32 64]CHANNELS: 2RATE: [44100 192000]PERIOD_TIME: (83 185760)PERIOD_SIZE: [16 8192]PERIOD_BYTES: [128 65536]PERIODS: [2 32]BUFFER_TIME: (166 371520)BUFFER_SIZE: [32 16384]BUFFER_BYTES: [128 65536]TICK_TIME: ALL--------------------arecord: set_params:1299: Sample format non availableAvailable formats:- S16_LE- S32_LE

author: Nominal Animal
author_rank: Super Contributor
timestamp: June 19, 2019, 11:09:34 pm
content: If you run (in normal Bash shell)Code:for ((i=0; i<10000; i++)); do printf '\x00\x00\x00\x00\x6d\x6a\x6d\x6a\x41\x76\x41\x76\xf8\x18\xf8\x18\x7e\xa5\x7e\xa5\x76\x82\x76\x82\x05\xcf\x05\xcf\x1c\x47\x1c\x47\xff\x7f\xff\x7f\x1c\x47\x1c\x47\x05\xcf\x05\xcf\x76\x82\x76\x82\x7e\xa5\x7e\xa5\xf8\x18\xf8\x18\x41\x76\x41\x76\x6d\x6a\x6d\x6a\x00\x00\x00\x00\x93\x95\x93\x95\xbf\x89\xbf\x89\x08\xe7\x08\xe7\x82\x5a\x82\x5a\x8a\x7d\x8a\x7d\xfb\x30\xfb\x30\xe4\xb8\xe4\xb8\x01\x80\x01\x80\xe4\xb8\xe4\xb8\xfb\x30\xfb\x30\x8a\x7d\x8a\x7d\x82\x5a\x82\x5a\x08\xe7\x08\xe7\xbf\x89\xbf\x89\x93\x95\x93\x95' ; done | aplay -D hw:CARD=PCH,DEV=0 --disable-resample --disable-channels --disable-format --disable-softvol -c 2 -f S16_LE -r 192000you should "hear" a couple of seconds of 30 kHz sine wave. Can you test that? The wavelength is 6.4 samples, and the binary data contains five full waves of full amplitude in S16_LE in stereo.Edit: Fixed the hex data.

author: jmelson
author_rank: Super Contributor
timestamp: June 20, 2019, 06:48:40 pm
content: Nope! I get :Playing raw data 'stdin' : Signed 16 bit Little Endian, Rate 192000 Hz, StereoWarning: rate is not accurate (requested = 192000Hz, got = 48000Hz)please, try the plug pluginAnd, the scope shows a 7.4 KHz sine wave (135 us between peaks).Thanks,Jon

author: Nominal Animal
author_rank: Super Contributor
timestamp: June 20, 2019, 07:10:33 pm
content: Make sure there is no other audio playing at the same time, and that arecord still responds the same way. Can you show whatCode:for ((i=0; i<10000; i++)); do printf '\x00\x00\x00\x00\x6d\x6a\x6d\x6a\x41\x76\x41\x76\xf8\x18\xf8\x18\x7e\xa5\x7e\xa5\x76\x82\x76\x82\x05\xcf\x05\xcf\x1c\x47\x1c\x47\xff\x7f\xff\x7f\x1c\x47\x1c\x47\x05\xcf\x05\xcf\x76\x82\x76\x82\x7e\xa5\x7e\xa5\xf8\x18\xf8\x18\x41\x76\x41\x76\x6d\x6a\x6d\x6a\x00\x00\x00\x00\x93\x95\x93\x95\xbf\x89\xbf\x89\x08\xe7\x08\xe7\x82\x5a\x82\x5a\x8a\x7d\x8a\x7d\xfb\x30\xfb\x30\xe4\xb8\xe4\xb8\x01\x80\x01\x80\xe4\xb8\xe4\xb8\xfb\x30\xfb\x30\x8a\x7d\x8a\x7d\x82\x5a\x82\x5a\x08\xe7\x08\xe7\xbf\x89\xbf\x89\x93\x95\x93\x95' ; done | aplay -D hw:CARD=PCH,DEV=0 --disable-resample --disable-channels --disable-format --disable-softvol -c 2 -f S16_LE -r 192000 -vie. adding -v, outputs?On this HP EliteBook 840 G4, with Intel Sunrise Point-LP HD Audio (HP 828c) with CX8200 Analog codec, the above works (even if it only advertises 48000 and 96000 sample rates). I do get the same error if I try to use any odd sample rate, like 144000 for example, except that 192000 gets used instead.

author: jmelson
author_rank: Super Contributor
timestamp: June 20, 2019, 07:12:45 pm
content: Quote from: magic on June 19, 2019, 10:17:03 pmThis looked REALLY promising, so I tried to hack the /etc/pulse/daemon.conf file to increase the default sample rate, it made no difference! DARN!Almost the entire file was originally commented out.Jon

author: jmelson
author_rank: Super Contributor
timestamp: June 20, 2019, 07:15:59 pm
content: Quote from: Nominal Animal on June 20, 2019, 07:10:33 pmOK, here's what I get :Playing raw data 'stdin' : Signed 16 bit Little Endian, Rate 192000 Hz, StereoWarning: rate is not accurate (requested = 192000Hz, got = 48000Hz)please, try the plug pluginHardware PCM card 0 'HDA Intel PCH' device 0 subdevice 0Its setup is:stream : PLAYBACKaccess : RW_INTERLEAVEDformat : S16_LEsubformat : STDchannels : 2rate : 48000exact rate : 48000 (48000/1)msbits : 16buffer_size : 16384period_size : 4096period_time : 85333tstamp_mode : NONEtstamp_type : MONOTONICperiod_step : 1avail_min : 4096period_event : 0start_threshold : 16384stop_threshold : 16384silence_threshold: 0silence_size : 0boundary : 4611686018427387904appl_ptr : 0hw_ptr : 0

author: NiHaoMike
author_rank: Super Contributor
timestamp: June 20, 2019, 07:22:04 pm
content: If you don't have any apps that require it, disable Pulseaudio and use plain ALSA.

author: jmelson
author_rank: Super Contributor
timestamp: June 20, 2019, 07:27:05 pm
content: Quote from: Nominal Animal on June 20, 2019, 07:10:33 pmOK, finally found the codec info in the dmesg output, it is an ALC3234 , from dmesg:[ 3.636362] snd_hda_codec_realtek hdaudioC0D0: autoconfig for ALC3234: line_outs=1 (0x1b/0x0/0x0/0x0/0x0) type:lineI don't know if that helps any.Thanks very much for all your help so far. (I can't figure out why changing the defaults in the daemon.conf file didn't fix this!)Jon

author: Nominal Animal
author_rank: Super Contributor
timestamp: June 20, 2019, 08:03:45 pm
content: (Theaplay -D hw:CARD=PCH,DEV=0uses the alsa hardware device directly. If you have pulseaudio playing at the same time, aplay will fail.)Quote from: jmelson on June 20, 2019, 07:15:59 pmI have the exact same output, except for the warning and that I get 192000 instead of 48000 in rate and exact rate.To me, it looks like your hardware does not support 192000 Hz sample rate; perhaps because the kernel driver fails or refuses to set it for your particular hardware. Thekernel driverhas a crapton of overrides for specific models, and thegeneric HD audio stuffindicates it just talks to the controller, trying to set what it advertises.Could you try if the rate changes if you useS32_LEinstead ofS16_LE? The listed data is not correct for that format, but that can be easily fixed if S32_LE can be played back at 192kHz.

author: jmelson
author_rank: Super Contributor
timestamp: June 20, 2019, 08:20:02 pm
content: Quote from: Nominal Animal on June 20, 2019, 08:03:45 pmI don't have anything else playing.Something I just found, with pacmd list-sinksis that index 0 is the Nvidia graphics card, and index 1 is the ALC3234, so maybe all this configuration setting is directed at the wrong port.I'm not sure how to direct the settings to the right port, though.I'll try what you suggest.Thanks,Jon

author: jmelson
author_rank: Super Contributor
timestamp: June 20, 2019, 08:22:51 pm
content: Specifying -f S32le caused the frequency to double, so I get 67 us or ~15 KHz, the -v output still shows rate : 48000Thanks,Jon

author: jmelson
author_rank: Super Contributor
timestamp: June 20, 2019, 08:29:55 pm
content: Quote from: jmelson on June 20, 2019, 08:20:02 pm

author: Nominal Animal
author_rank: Super Contributor
timestamp: June 20, 2019, 08:33:39 pm
content: RunCode:aplay -Lto list all devices you can use. The device name starts at the first column. My list isCode:defaultPlayback/recording through the PulseAudio sound servernullDiscard all samples (playback) or generate zero samples (capture)pulsePulseAudio Sound Serversysdefault:CARD=PCHHDA Intel PCH, CX8200 AnalogDefault Audio Devicefront:CARD=PCH,DEV=0HDA Intel PCH, CX8200 AnalogFront speakerssurround21:CARD=PCH,DEV=0HDA Intel PCH, CX8200 Analog2.1 Surround output to Front and Subwoofer speakerssurround40:CARD=PCH,DEV=0HDA Intel PCH, CX8200 Analog4.0 Surround output to Front and Rear speakerssurround41:CARD=PCH,DEV=0HDA Intel PCH, CX8200 Analog4.1 Surround output to Front, Rear and Subwoofer speakerssurround50:CARD=PCH,DEV=0HDA Intel PCH, CX8200 Analog5.0 Surround output to Front, Center and Rear speakerssurround51:CARD=PCH,DEV=0HDA Intel PCH, CX8200 Analog5.1 Surround output to Front, Center, Rear and Subwoofer speakerssurround71:CARD=PCH,DEV=0HDA Intel PCH, CX8200 Analog7.1 Surround output to Front, Center, Side, Rear and Woofer speakershdmi:CARD=PCH,DEV=0HDA Intel PCH, HDMI 0HDMI Audio Outputhdmi:CARD=PCH,DEV=1HDA Intel PCH, HDMI 1HDMI Audio Outputhdmi:CARD=PCH,DEV=2HDA Intel PCH, HDMI 2HDMI Audio Outputhdmi:CARD=PCH,DEV=3HDA Intel PCH, HDMI 3HDMI Audio Outputhdmi:CARD=PCH,DEV=4HDA Intel PCH, HDMI 4HDMI Audio Outputdmix:CARD=PCH,DEV=0HDA Intel PCH, CX8200 AnalogDirect sample mixing devicedmix:CARD=PCH,DEV=3HDA Intel PCH, HDMI 0Direct sample mixing devicedmix:CARD=PCH,DEV=7HDA Intel PCH, HDMI 1Direct sample mixing devicedmix:CARD=PCH,DEV=8HDA Intel PCH, HDMI 2Direct sample mixing devicedmix:CARD=PCH,DEV=9HDA Intel PCH, HDMI 3Direct sample mixing devicedmix:CARD=PCH,DEV=10HDA Intel PCH, HDMI 4Direct sample mixing devicedsnoop:CARD=PCH,DEV=0HDA Intel PCH, CX8200 AnalogDirect sample snooping devicedsnoop:CARD=PCH,DEV=3HDA Intel PCH, HDMI 0Direct sample snooping devicedsnoop:CARD=PCH,DEV=7HDA Intel PCH, HDMI 1Direct sample snooping devicedsnoop:CARD=PCH,DEV=8HDA Intel PCH, HDMI 2Direct sample snooping devicedsnoop:CARD=PCH,DEV=9HDA Intel PCH, HDMI 3Direct sample snooping devicedsnoop:CARD=PCH,DEV=10HDA Intel PCH, HDMI 4Direct sample snooping devicehw:CARD=PCH,DEV=0HDA Intel PCH, CX8200 AnalogDirect hardware device without any conversionshw:CARD=PCH,DEV=3HDA Intel PCH, HDMI 0Direct hardware device without any conversionshw:CARD=PCH,DEV=7HDA Intel PCH, HDMI 1Direct hardware device without any conversionshw:CARD=PCH,DEV=8HDA Intel PCH, HDMI 2Direct hardware device without any conversionshw:CARD=PCH,DEV=9HDA Intel PCH, HDMI 3Direct hardware device without any conversionshw:CARD=PCH,DEV=10HDA Intel PCH, HDMI 4Direct hardware device without any conversionsplughw:CARD=PCH,DEV=0HDA Intel PCH, CX8200 AnalogHardware device with all software conversionsplughw:CARD=PCH,DEV=3HDA Intel PCH, HDMI 0Hardware device with all software conversionsplughw:CARD=PCH,DEV=7HDA Intel PCH, HDMI 1Hardware device with all software conversionsplughw:CARD=PCH,DEV=8HDA Intel PCH, HDMI 2Hardware device with all software conversionsplughw:CARD=PCH,DEV=9HDA Intel PCH, HDMI 3Hardware device with all software conversionsplughw:CARD=PCH,DEV=10HDA Intel PCH, HDMI 4Hardware device with all software conversionsOf those, the ones that start withhw:are direct hardware devices, without any conversions. Since I am not using HDMI for audio output, the only possible one for me washw:CARD=PCH,DEV=0.Just use the device you want, in the aplay command, following the-Dflag.

author: jmelson
author_rank: Super Contributor
timestamp: June 20, 2019, 08:42:27 pm
content: OK, it starts with :defaultPlayback/recording through the PulseAudio sound servernullDiscard all samples (playback) or generate zero samples (capture)pulsePulseAudio Sound Serversysdefault:CARD=PCHHDA Intel PCH, ALC3234 AnalogDefault Audio Devicefront:CARD=PCH,DEV=0HDA Intel PCH, ALC3234 AnalogFront speakers. . . then there's :hw:CARD=PCH,DEV=0HDA Intel PCH, ALC3234 AnalogDirect hardware device without any conversionsplughw:CARD=PCH,DEV=0HDA Intel PCH, ALC3234 AnalogHardware device with all software conversionsand then a bunch of stuff pointing at the Nvidia board.It just doesn't make sense that hw:CARD=PCH,DEV=0 would be restricted to 48K, does it?Thanks,Jon

author: jmelson
author_rank: Super Contributor
timestamp: June 20, 2019, 09:01:19 pm
content: OK, so I tried playing with different devices, and when I use -D dmix:CARD=PCH,DEV=0 then I do not get the message about the sample rate going to 48k, and it looks like it might be doing 96K, as I get 68 us or 15 KHz with the S16_LE format.Jon

author: jmelson
author_rank: Super Contributor
timestamp: June 20, 2019, 09:12:04 pm
content: And, now, I've screwed something up! When I try to aplay a file with -f S16_LE, I get this :Playing raw data 'stdin' : Signed 16 bit Little Endian, Rate 192000 Hz, Stereoaplay: set_params:1299: Sample format non availableAvailable formats:- S32_LEI put the original /etc/pulse/daemon.conf file back and rebooted, but I'm still getting this error. -f S32_LE works, but still at 48000 samples/sec.Hmm, more interesting -- dmix:CARD=PCH,DEV=0 seems to require S32_LE, but hw:CARD=PCH,DEV=0 will accept S16_LE.So, false alarm, mostly.Jon

author: jmelson
author_rank: Super Contributor
timestamp: June 20, 2019, 09:31:34 pm
content: Well, using aplay and pointing it to the hw: device on a different computer, I was able to play the 30 KHz sine wave at both 96k and 192k sample rates!I still don't know why my desktop won't do it, though.Thanks VERY MUCH for your extensive help, Nominal Animal, you have been HUGELY helpful in getting this working.Jon

author: Nominal Animal
author_rank: Super Contributor
timestamp: June 20, 2019, 09:34:41 pm
content: Quote from: jmelson on June 20, 2019, 08:42:27 pmLet's check the relevantthe Linux driver.ALC3234 is identified by 0x10ec0255, 0x1028, on line 977.On line 4308, the coef0255 table is supplied to the alc_process_coef_fw() function; it is possible that this is not exactly correct for your hardware (for it to support 192kHz sample rate), and therefore only the 48kHz sample rate -- which, after all, is what almost all people will use anyway -- is actually supported. You can see here that there are tens of variants of this codec that require fixups/quirks on some hardware.On line 7816, ALC3234 is named as theALC269_TYPE_ALC255variant.Line 3702 declares a function namedalc269_fixup_pcm_44k(), with a comment that"Due to a hardware problem on Lenovo Ideadpad, we need to fix the sample rate of analog I/O to 44.1kHz". While it is only applied on Quanta FL1s (see line 7101), and not on your machine, this indicates that the ALC269 base family (to which your ALC3234 belongs)hashad issues with sample rates not working; and therefore I must say, it actuallydoes make sensethat you have problems with sample rates other than the default 48000.(Thedmixdevices are not "pure hardware"; seehere. It is a stream mixer. You want to use thehw:devices only, to get true sample rates and exact output.)

author: jmelson
author_rank: Super Contributor
timestamp: June 20, 2019, 10:37:22 pm
content: Wow, you have obviously gone WAY deeper into Linux audio than I ever will! Thanks for the info, not the first time I've run into intel motherboard chipsets that have problems with certain Linux drivers.Jon