Applied Math for Creative Coders
  1. Math Models for Creative Coders
  2. Tech
  3. Using Constructor Objects in p5.js
  • Math Models for Creative Coders
    • Maths Basics
      • Vectors
      • Matrix Algebra Whirlwind Tour
      • Things at Right Angles
      • content/courses/MathModelsDesign/Modules/05-Maths/70-MultiDimensionGeometry/index.qmd
    • Tech
      • Tools and Installation
      • Adding Libraries to p5.js
      • Using Constructor Objects in p5.js
      • The Open Sound Protocol
    • Geometry
      • Circles
      • Complex Numbers
      • Fractals
      • Affine Transformation Fractals
      • L-Systems
      • Kolams and Lusona
    • Media
      • Fourier Series
      • Additive Sound Synthesis
      • Making Noise Predictably
      • The Karplus-Strong Guitar Algorithm
    • AI
      • Working with Neural Nets
      • The Perceptron
      • The Multilayer Perceptron
      • MLPs and Backpropagation
      • Gradient Descent
    • Projects
      • Projects

On this page

  • Introduction
  • Examples of Objects
    • Objects in the p5.sound library
    • Creating our own Obects
  • References
  1. Math Models for Creative Coders
  2. Tech
  3. Using Constructor Objects in p5.js

Using Constructor Objects in p5.js

p5.js

Introduction

p5.js allows us to use Javascript features such as Objects. An Object in p5.js is a form of data + a set of things you can do with that data, what are called methods. Think of an Object as a spanner in your toolkit, which can tell you the gauge/size of mechanical components and also do specific things with these.

When would we need to use these?

Some libraries in p5.js, such as p5.sound create Oscillator objects, which can generate sounds with different frequencies. And these have methods associated with them, such as turning them on/off, modifying their amplitudes and frequencies (“modulations”).

We can also create our own Objects which can include some methods of their own.

Examples of Objects

Let us see an example of a built-in Object type offered by p5.js. Then we will look at the way in which we can create Objects of our own.

Objects in the p5.sound library

Creating our own Obects

References

  1. Dan Shiffman, of course:
  1. https://www.cs.cmu.edu/~tcortina/15104-f20/lectures/24-MoreSound.pdf
Back to top
Adding Libraries to p5.js
The Open Sound Protocol

License: CC BY-SA 2.0

Website made with ❤️ and Quarto, by Arvind V.

Hosted by Netlify .