# Give sound to AI paths

**URL:** <https://discourse.processing.org/t/give-sound-to-ai-paths/31660>\
**Category:** Coding Questions\
**Created:** [August 10, 2021, 10:13am UTC](https://discourse.processing.org/t/give-sound-to-ai-paths/31660 "2021-08-10T10:13:00Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [August 11, 2021, 11:05am UTC](https://discourse.processing.org/t/give-sound-to-ai-paths/31660/3 "2021-08-11T11:05:22Z")

</div>

Hello,

I provided a very short list of initial thoughts… this certainly has me thinking about it!

A good place to start:

> **Click here for resources**
>
> I encourage you to look at the resources available here:
> 
> **Beginner**
> 
> - The Processing website has _references_ , _examples_ , _tutorials_ , etc.  
> [https://processing.org/](https://processing.org/)
> 
> - The Processing PDE (IDE) has lots to offer!  
> An exploration of the menu items will reveal what is available!  
> You will find _libraries_ , _tools_ , _examples_ and more!  
> For example:  
> ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/d/d1f59b878cb30a4047dbfd8407702c77bc49bca6.png)
> 
> **Advanced**
> 
> - The source code can give insight if you are adventurous:  
> [GitHub - processing/processing: Source code for the Processing Core and Development Environment (PDE)](https://github.com/processing/processing)  
> Many of the Processing functions are here:  
> [https://github.com/processing/processing/blob/master/core/src/processing/core/PApplet.java](https://github.com/processing/processing/blob/master/core/src/processing/core/PApplet.java)
> - And the Internet.

> [@markelloskolofotias](#):
>
> So, could you please tell me if there is a way for Processing to scan these symbols, go along/ follow their paths and as a result give them sound? (I hope I explained myself well enough!)

There is always a way…

**Scan these symbols**

Extract an individual PImage for each symbol from your picture.  
Use a camera with the video library and extract a PImage.

**Go along/ follow their paths**

If you want to follow the curve on a picture this is one very simple example:

> [@How to rotate a sprite toward the direction of motion](https://discourse.processing.org/t/how-to-rotate-a-sprite-toward-the-direction-of-motion/21056/12):
>
> Hello, You need the slope of the curve at that point to get the angle. If you do not have an equation to the curve (for derivative) you will have to use two points on the curve close to your plot point (I used data in an array; an index higher an index lower) to approximate. See below for example. I got this to work nicely and animated it as well; the tangent moved across the curve. This is a Processing (Java) snippet to get you thinking about this: PVector [] data; //Slope using atan() …

I shared the above to illustrate that it can be done.

There may be libraries that are useful:  
[http://www.ricardmarxer.com/geomerative/](http://www.ricardmarxer.com/geomerative/) This came to mind… it is a maybe.  
I am sure there are others!

**A result give them sound**

There are a few sound libraries to use. Seek them out.

Another reference:

> **[Images and Pixels](https://processing.org/tutorials/pixels/)**
>
> How to load and display images as well as access their pixels.

Check out the libraries:

> **[Libraries](https://processing.org/reference/libraries/)**
>
> Extend Processing beyond graphics and images into audio, video, and communication with other devices.

I did write some code to extract the individual symbols for later Processing:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/c/c9b260a1dfee4b65c1b6695760be7359b8376b98.png)

I provided the simplest example; the picture shows the images “shuffled” in some more advanced code I wrote.

> **Click here to see code**
>
> ```auto
> PImage symbol []; // Array of individual symbols
> PImage symbols; // Pimage of all symbols
> IntList num; // Array to shuffle
> 
> int xsp;
> int ysp;
> 
> void setup() 
> {
> size(700, 500);
> symbols = loadImage("symbols.jpg");
> println(symbols.width, symbols.height);
> symbol = new PImage[20];
> 
> xsp = 127;
> ysp = 108;
>   
> // Creates PImage array
> for(int y = 0; y<4; y++)
> {
> for(int x = 0; x<5; x++)
> {
> int n = x+y*5;
> println(x, y, n); 
> symbol[n] = symbols.get(x*xsp+25, y*ysp+25, xsp, ysp);
> }
> }
> 
> //Displays PImage array
> for(int y = 0; y<4; y++)
> {
> for(int x = 0; x<5; x++)
> {
> int n = x+y*5;
> println(x, y, n); 
> image(symbol[19-n], x*(xsp+5)+20, y*(ysp+5)+20);
> }
> }
> }
> 
> ```

Also thinking about what can be done with an SVG… `:)`

I can’t comment on the AI part…

`:)`

---

_[View the full topic](https://discourse.processing.org/t/give-sound-to-ai-paths/31660)._
