Here’s a README for your project:
This project allows users to visualize mathematical functions as graphs and listen to their audio representations in real-time. The tool enables interactive graph generation, dynamic function definition, and audio playback using Tone.js. It is designed with a dark and light mode theme and provides intuitive input fields for function expression, as well as configurable lower and upper limits for the x-axis.
- Graphing Function: Enter a mathematical function for
f(x)
(e.g.,Math.sin(x)
,3*x + 1
, orcollatz
). - Audio Visualization: Hear the audio playback of the graph as a series of musical notes.
- Dynamic Limits: Adjust the range of the x-axis (lower and upper limits).
- Dark/Light Mode: Toggle between dark and light themes.
- Reset: Reset the graph, input fields, and audio state to their default values.
- Frontend:
- React (via Remix)
- TailwindCSS for styling
- MathJS (instead of eval() )
- Backend:
- Tone.js for audio synthesis
- Canvas API: For rendering graphs dynamically
- JavaScript: For evaluating mathematical functions and handling interactivity
To set up the project locally, follow these steps:
-
Clone the repository:
git clone https://github.com/debadityamalakar/graph-audio-visualizer.git
-
Install dependencies:
cd graph-audio-visualizer npm install
-
Run the development server:
npm run dev
-
Open your browser and navigate to
http://localhost:3000
to see the project in action.
- Input the function: In the
f(x)
input field, enter a valid JavaScript mathematical expression, such asMath.sin(x)
,x * x
, or3 * x + 1
. - Collatz Function: If you enter
collatz
, it will generate the Collatz sequence for a given starting value.
- Lower Limit: Set the starting point for the x-axis. This determines where the graph begins.
- Upper Limit: Set the endpoint for the x-axis. The graph will be generated for all x values between the lower and upper limits.
- Generate Graph: After setting the function and limits, click the Generate Graph button to display the graph.
- Play Audio: Click the Play Audio button to start playing an audio representation of the graph.
- Stop Audio: Stop the audio playback with the Stop Audio button.
- Reset: Reset the input fields, graph, and audio state by clicking the Reset button.
Toggle between dark and light themes by clicking the Dark Mode / Light Mode button in the top-right corner.
/graph-audio-visualizer
├── /public
│ └── /assets
│ └── (static assets like images)
├── /src
│ ├── /components
│ ├── /styles
│ ├── /utils
│ └── /pages
├── /package.json
├── /tailwind.config.js
├── /tsconfig.json
└── /README.md
Contributions are welcome! To contribute, please fork the repository and create a pull request. Ensure that your code is clean and well-documented. If you're adding new features, please update the README accordingly.
This project is open-source and available under the MIT License.
- Tone.js: For handling audio synthesis and playback.
- React: For building the user interface.
- TailwindCSS: For rapid and responsive styling.
- Canvas API: For rendering the dynamic graph.
For questions or inquiries, feel free to reach out via email.
Let me know if you need any additional information in the README!