Skip to content

Instantly share code, notes, and snippets.

View rknightly's full-sized avatar

Ryan Knightly rknightly

View GitHub Profile
@rknightly
rknightly / noteToFrequency.swift
Last active May 14, 2020 06:35
A Swift function that converts a note (eg. "A4") to a frequency (eg. 440.0)
// MIT License
// Swift that converts a string note (eg. "A4") to a frequency (eg. 440.0).
// Inspired by https://gist.github.com/stuartmemo/3766449
static func noteToFrequency (note: String) -> Double {
let notes = ["A", "A#", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#"]
let octave = Double(String(note.last!))!
var keyNumber = Double(notes.firstIndex(of: String(note.dropLast()))!)
if (keyNumber < 3) {
keyNumber += octave * 12 + 1
@rknightly
rknightly / ProblemName.java
Last active October 11, 2018 20:53
UIL Solution Template
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import static java.lang.System.out; // allow use of out.println() without System
public class ProblemName {
// CHANGE FILE NAME FOR EACH PROBLEM!
private static final String inputFileName = "filename00.dat";
private static Scanner scan;