# Get n-th harmonic of acquisition by API

**URL:** https://forum.quantasylum.com/t/get-n-th-harmonic-of-acquisition-by-api/1618
**Category:** QA40x
**Created:** [November 6, 2024, 7:36pm UTC](https://forum.quantasylum.com/t/get-n-th-harmonic-of-acquisition-by-api/1618 "2024-11-06T19:36:30Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![breedj](https://avatars.discourse-cdn.com/v4/letter/b/df788c/32.png) [@breedj](https://forum.quantasylum.com/u/breedj)
#### Post date: [November 6, 2024, 7:36pm UTC](https://forum.quantasylum.com/t/get-n-th-harmonic-of-acquisition-by-api/1618/1 "2024-11-06T19:36:30Z")

</div>

I’ve been using Arta and Steps for years before I got the QA403. The Steps program was able to create a graph which plots the first 6 harmonics over frequency which is assential when designing an amplifier. I think I need the same data wich is displayed in the THD Bargraph visualizer. I could not find any sourcecode of [ThdBargraph] How can I get the n-th harmonic via the REST api after doing an acquisition? Or do I have to process the fft data myself for that?  
I want to create an opensource c# program which plots this graph:

 ![Distortion vs Frequency % - 8 Ohm](https://canada1.discourse-cdn.com/flex032/uploads/quantasylum/original/2X/9/9403aa503a4543aade38caa683cad288fe362033.png)

Thanks.

---

<div class="post-metadata">

### Author: ![breedj](https://avatars.discourse-cdn.com/v4/letter/b/df788c/32.png) [@breedj](https://forum.quantasylum.com/u/breedj)
#### Post date: [November 6, 2024, 8:39pm UTC](https://forum.quantasylum.com/t/get-n-th-harmonic-of-acquisition-by-api/1618/2 "2024-11-06T20:39:18Z")

</div>

I think I figured it out. I got the idea to use wireshark and see what ThdBargraph does.

 ![{C9D53270-C126-409F-8D97-824566FBE7F9}](https://canada1.discourse-cdn.com/flex032/uploads/quantasylum/original/2X/3/3557b4fd4faf8431a18d7605159a4ae0adb47fa9.png)

I will create an application which sets the generator to a certain frequency and then I will get the harmonics by calculating the bins and get their value with PeakDbv.

---

<div class="post-metadata">

### Author: ![matt](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@matt](https://forum.quantasylum.com/u/matt)
#### Post date: [November 9, 2024, 12:25am UTC](https://forum.quantasylum.com/t/get-n-th-harmonic-of-acquisition-by-api/1618/3 "2024-11-09T00:25:37Z")

</div>

Hi @breedj, via REST you can run an acquisition, and then ask the REST server to compute the THD for you. For example, if you did the acq with a 1 kHz tone and wanted to look at all harmonics through 20k that would be:

`GET localhost:9402/ThdDb/1000/20000`

Note that you can adjust the stop frequency for the calc. So, if you want to look at the THD with a 100 Hz fundamental with just the harmonics up to and including 500 Hz you could issue:

`GET localhost:9402/ThdDb/100/500`

That would return the left/right channel THD ratio expressed in dB. You can also do ThdPct if you’d like in percent.

---

<div class="post-metadata">

### Author: ![matt](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@matt](https://forum.quantasylum.com/u/matt)
#### Post date: [November 9, 2024, 12:26am UTC](https://forum.quantasylum.com/t/get-n-th-harmonic-of-acquisition-by-api/1618/4 "2024-11-09T00:26:50Z")

</div>

BTW, have you seen the REST API? Hit the link below with the QA40x app running and it should dump the entire API.

`http://localhost:9402/`

---

<div class="post-metadata">

### Author: ![breedj](https://avatars.discourse-cdn.com/v4/letter/b/df788c/32.png) [@breedj](https://forum.quantasylum.com/u/breedj)
#### Post date: [November 9, 2024, 8:28am UTC](https://forum.quantasylum.com/t/get-n-th-harmonic-of-acquisition-by-api/1618/5 "2024-11-09T08:28:29Z")

</div>

Thanks Matt. I’ve discovered the api and already started using it. I think it is perfect for what I like to do and easy to use. I will use PeakDbv instead of ThdDb because it does not give me the distortion of the single harmonics, only a range where the start is always the fundamental. But I have tested PeakDbv where you can specify a custom frequency range and it is perfect for what I need. And I noticed I can also use /Data/Frequency/Input and do my own calculations as well.

I will post a link to the repository of my program after I’ve have made a working version. I will first compare the results with some other systems like Audio Precision.
