Skip to content

Instantly share code, notes, and snippets.

View joshstovall's full-sized avatar
😎
coding

Josh Stovall joshstovall

😎
coding
View GitHub Profile
@joshstovall
joshstovall / pythagorean.js
Last active September 10, 2021 07:30
pythagorean.js
function pythagorean(e){
var frequency = e;
var cents;
// multiply/divide frequency until between 440 & 880
for (let step = 0; step < 100; step++) {
if (frequency < tuningHz) { frequency = frequency * 2; }
else if (frequency > tuningHz * 2) { frequency = frequency / 2; }
else { break; }
}
@joshstovall
joshstovall / ratio.js
Created September 10, 2021 07:32
pythagorean tuning ratios
// pythagorean tuning ratios
var ratio = [
1/1, // unision
256/243, // minor second
9/8, // major second
32/27, // minor third
81/64, // major third
4/3, // perfect fourth
729/512, // tritone
3/2, // perfect fifth
function getMicrophone() {
}
@joshstovall
joshstovall / midi.js
Created September 10, 2021 07:45
midi.js
// pianos
var leftMIDI = JZZ.input.Kbd({at:'leftMIDI' , from:'C5', to:'B5', onCreate:function() {}});
var rightMIDI = JZZ.input.Kbd({at:'rightMIDI', from:'C5', to:'B5', onCreate:function() {}});
var synth = JZZ.synth.Tiny();
rightMIDI.connect(synth);
leftMIDI.connect(synth);
// midi out
var midi_out = JZZ.gui.SelectMidiOut({ at: 'midi_out' });
function getTweets(symbol) {
request({
url: 'https://api.twitter.com/1.1/search/tweets.json?q=' + formatQuery(symbol),
headers: { 'Authorization': 'Bearer ' + TWITTER_API_KEY }
}, sentimentAnalysis)
}
function cleanTweet(e){
return e.text
.replace(/\n|\r/g, "")
.replace(/(?:https?|ftp):\/\/[\n\S]+/g, '') // remove URLs
.replace(/\@[^\s]*/g, "") // remove @ mentions
.replace(/\$[^\s]*/g, "") // remove $ cashtags
.replace(/\#[^\s]*/g, "") // remove # hashtags
.replace('RT', '') // replace RT in retweet tweets
.replace('NEW', '')
.replace('// // ', '')
var custom = {
'yas':3,
'bruh':-1,
'🚀': 5,
'🔥': 3,
'💩': -2
}
function formatQuery(e) {
return '$' + e + handles[e] ? ' @' + e[e] : ""
}
const fs = require('fs')
const request = require('request')
const Sentiment = require('sentiment')
function sentimentAnalysis() {
var tweets = JSON.parse(body).statuses
tweets = JSON.parse(body).statuses.map(function (e) {
// clean tweet
var tweet = clean(e.text)
// sentiment analysis
var result = new Sentiment().analyze(tweet, {
extras: words