---
title: TarsosDSP PureData or MAX MSP external
canonical: https://0110.be/posts/TarsosDSP_PureData_or_MAX_MSP_external
markdown_url: https://0110.be/posts/TarsosDSP_PureData_or_MAX_MSP_external.md
id: 423
published_at: '2014-09-05T00:00:00Z'
updated_at: '2025-11-29T22:18:15Z'
author: Joren
tags:
- name: TarsosDSP
  markdown_url: https://0110.be/tags/TarsosDSP.md
- name: UGent
  markdown_url: https://0110.be/tags/UGent.md
---

# TarsosDSP PureData or MAX MSP external

<img src="https://0110.be/files/attachments/423/pd_tarsosdsp.png" alt="Pitch detection pure data patch" style="float:left;margin-right:1.5rem;margin-bottom:1.5rem"> It makes sense to connect TarsosDSP, a real-time audio processing library written in Java, with patcher environments such as Pure Data and Max/MSP. Both Pure Data and Max/MSP offer the capability to code object, or externals using Java. In Pure Data this is done using the `pdj~` object, which should be compatible with the Max/MSP implementation. This post demonstrates a patch that connects an oscillator with a pitch tracking algorithm implemented in TarsosDSP.

To the left you can see the finished patch. When it is working an audio stream is generated using an oscillator. The frequency of the oscillator can be controlled. Subsequently the stream is send to the Java environment with the `pdj` bridge. The Java environment receives an array of floats, representing the audio. A pitch estimation algorithm tries to find the pitch of the audio represented by the buffer. The detected pitch is returned to the pd environment by means of outlet. In pd, the detected pitch is shown and used for auditory feedback.

````java
PitchDetectionResult result = yin.getPitch(audioBuffer);
pitch = result.getPitch();
outlet(0, Atom.newAtom(pitch));
````

Please note that the pitch detection algorithm can handle any audio stream, not only pure sines. The example here demonstrates the most straightforward case. Using this method all algorithms implemented in TarsosDSP can be used in Pure Data. These range from onset detection to filtering, from audio effects to wavelet compression. For a list of features, please see the [TarsosDSP github page](https://github.com/JorenSix/TarsosDSP). Here, the source for this patch [implementing pitch tracking in pd](https://0110.be/files/attachments/423/tarsosdsp_pd_external.zip) can be downloaded. To run it, extract it to a directory and simply run the `pitch.pd` patch. Pure Data should load `pdj~` automatically together with the classes present in the `classes` directory.


- [tarsosdsp\_pd\_external.zip](https://0110.be/files/attachments/423/tarsosdsp_pd_external.zip)

- [pd\_tarsosdsp.png](https://0110.be/files/attachments/423/pd_tarsosdsp.png)
