<commit_before>import { TestAudioBuffer } from "@tonejs/plot";
import { Context } from "Tone/core/context/Context";
import { OfflineContext } from "Tone/core/context/OfflineContext";
import { isFunction } from "Tone/core/util/TypeCheck";

type ReturnFunction = (time: Seconds) => void;

export async function Offline(
	callback: (context: OfflineContext) => void | ReturnFunction | Promise<void | ReturnFunction> | void,
	duration = 0.1, channels = 1,
) {
	const originalContext = Context.getGlobal();
	const offline = new OfflineContext(channels, duration, 44100);
	Context.setGlobal(offline);
	let retFunction = callback(offline);
	if (retFunction instanceof Promise) {
		retFunction = await retFunction;
	}
	if (isFunction(retFunction)) {
		const fn = retFunction;
		offline.on("tick", () => fn(offline.now()));<commit_msg>test takes sample rate<commit_after>import { TestAudioBuffer } from "@tonejs/plot";
import { Context } from "Tone/core/context/Context";
import { OfflineContext } from "Tone/core/context/OfflineContext";
import { isFunction } from "Tone/core/util/TypeCheck";

type ReturnFunction = (time: Seconds) => void;

export async function Offline(
	callback: (context: OfflineContext) => void | ReturnFunction | Promise<void | ReturnFunction> | void,
	duration = 0.1, channels = 1, sampleRate: number = 44100,
) {
	const originalContext = Context.getGlobal();
	const offline = new OfflineContext(channels, duration + 1 / sampleRate, sampleRate);
	Context.setGlobal(offline);
	let retFunction = callback(offline);
	if (retFunction instanceof Promise) {
		retFunction = await retFunction;
	}
	if (isFunction(retFunction)) {
		const fn = retFunction;
		offline.on("tick", () => fn(offline.now()));
{'fraction_non_alphanumeric': 0.1315020455873758, 'fraction_numerical': 0.009935710111046173, 'mean_word_length': 5.559386973180077, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3478098', 'n_tokens_mistral': 536, 'n_tokens_neox': 512, 'n_words': 135}