asteroidblock
A web-based synthesizer that queries NASA realtime asteroid data.
Sat Jan 01 2022
Visit asteroidblock.
Asteroidblock is a web-based synthesizer that leverages NASA's asteroid proximity data to influence sound generation in real-time. By querying NASA's API, Asteroidblock translates celestial parameters into dynamic audio experiences, bridging the gap between space data and sound synthesis.
Project Overview
Asteroidblock is designed to create an interactive auditory experience by mapping real-time asteroid data to synthesizer parameters.
The synthesizer takes into account various factors such as the speed and proximity of asteroids, and whether they pose any potential danger. This data-driven approach allows for a unique synthesis of scientific information and artistic expression.
Functional Implementation
Built entirely with JavaScript, Asteroidblock operates on an open-source framework, making it accessible for developers and programmers to explore and contribute. The synthesizer queries NASA's asteroid proximity API, processing parameters like asteroid speed and proximity to influence sound characteristics in real-time.
Additionally, it assesses whether an asteroid is potentially hazardous, adjusting modulation effects accordingly.
fetchData: async () => {
let asteroids = [];
let data;
const asteroidCookie = Cookies.get('asteroids');
if (asteroidCookie) {
asteroids = JSON.parse(asteroidCookie);
} else {
const today = new Date().toISOString().split('T')[0];
data = await fetchAsync(
`https://api.nasa.gov/neo/rest/v1/feed?start_date=${today}&end_date=${today}&api_key=YOUR_API_KEY`
);
if (!data || !data.near_earth_objects) {
data = backup;
}
if (data.near_earth_objects[today]) {
// Process and store asteroid data
asteroids = data.near_earth_objects[today].map(a => ({
name: a.name,
hazardous: a.is_potentially_hazardous_asteroid.toString(),
close_approach_date: a.close_approach_data[0].close_approach_date,
orbiting_body: a.close_approach_data[0].orbiting_body,
diameter: parseFloat(
a.estimated_diameter.kilometers.estimated_diameter_max.toFixed(3)
),
miss_distance: parseFloat(
a.close_approach_data[0].miss_distance.kilometers.toFixed(3)
),
velocity: parseFloat(
a.close_approach_data[0].relative_velocity.miles_per_hour.toFixed(3)
)
}));
}
Cookies.set('asteroids', asteroids, { expires: 1 });
}
Asteroid.asteroids = asteroids;
Asteroid.selected = Asteroid.asteroids[0];
Asteroid.renderInfo(0);
Asteroid.eventListener();
},
User Interface
The user interface of Asteroidblock is straightforward, featuring a basic UI that enables users to select different asteroids. This selection process allows users to experience how various asteroids impact the synthesized sound, providing an interactive element that enhances user engagement.
The interface serves as a gateway for users to explore the relationship between asteroid data and audio output seamlessly.
macro = (effect, effectParams) => {
const influencedBy = Effects.data[effect].paramaters[effectParams].influencedBy;
if (!influencedBy) {
return;
}
const currInfluencedVal = Asteroid.selected[influencedBy];
const values = Asteroid.asteroids.map(a => a[influencedBy]);
const influencedByRange = [Math.min(...values), Math.max(...values)];
const currInfluencePercentage = Effects.percentageInRangeGivenValue(
currInfluencedVal,
influencedByRange
);
const effectRange = Effects.data[effect].paramaters[effectParams].range;
const valInRange = Effects.valueInRangeFromPercentage(
currInfluencePercentage,
effectRange
);
Effects.updateEffectValFromAsteroid(effect, effectParams, valInRange);
};
Development Process
Asteroidblock integrates real-time asteroid data into a functional synthesizer. The process involved setting up the necessary environment, ensuring seamless data retrieval from NASA's API, and mapping the retrieved parameters to sound synthesis processes.
The project is open-sourced, for anyone curious to play around with the codebase.
Thank you for reading.
[d.a]