<commit_before>package DDG::Goodie::BPMToMs;
# ABSTRACT: Converts Beats Per Minute to note values in milliseconds.
# Useful when needing to calculate delay times, attack / release times of compressors, reverb lengths etc.

use DDG::Goodie;

zci answer_type => "bpmto_ms";
zci is_cached   => 1;

name "BPM (beats per minute) to ms (milliseconds) converter";
description "Takes a tempo as BPM (beats per minute), eg. 120, and returns the corresponding note values as milliseconds.";
primary_example_queries "120 bpm to ms";
category "conversions";
topics "music";
code_url "https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/BPMToMs.pm";
attribution github => ["https://github.com/stefolof", "stefolof"],
            twitter => "stefolof";

triggers end => "bpm to ms";

handle remainder => sub {
	return unless $_; # Guard against "no answer"
    return unless $_ =~ /^\d+$/i; # Only integer values accepted
    
    return html => "<div class=\"record\">
                    <table style=\"border-spacing: 10px; border-collapse: separate;\" class=\"record__body\">
                        <tr class=\"record__row record__highlight\">
                            <td>Whole Note:</td><td>" . 240000 / $_ . " ms</td>
                            <td>Triplet:</td><td>" . 160000 / $_ . " ms</td>
                            <td>Dotted:</td><td>" . 360000 / $_ . " ms</td>
                        </tr>
                        <tr class=\"record__row record__highlight\">
                            <td>Half Note:</td><td>" . 120000 / $_ . " ms</td>
                            <td>Triplet:</td><td>" . 80000 / $_ . " ms</td>
                            <td>Dotted:</td><td>" . 180000 / $_ . " ms</td>
                        </tr>
                        <tr class=\"record__row record__highlight\">
                            <td>Quarter Note:</td><td>" . 60000 / $_ . " ms</td>
                            <td>Triplet:</td><td>" . 40000 / $_ . " ms</td>
                            <td>Dotted:</td><td>" . 90000 / $_ . " ms</td>
                        </tr>
                        <tr class=\"record__row record__highlight\">
                            <td>1/8 Note:</td><td>" . 30000 / $_ . " ms</td>
                            <td>Triplet:</td><td>" . 20000 / $_ . " ms</td>
                            <td>Dotted:</td><td>" . 45000 / $_ . " ms</td>
                        </tr>
                        <tr class=\"record__row record__highlight\">
                            <td>1/16 Note:</td><td>" . 15000 / $_ . " ms</td>
                            <td>Triplet:</td><td>" . 10000 / $_ . " ms</td>
                            <td>Dotted:</td><td>" . 22500 / $_ . " ms</td>
                        </tr>
                        <tr class=\"record__row record__highlight\"><commit_msg>Fixed hard tab -> 4 spaces<commit_after>package DDG::Goodie::BPMToMs;
# ABSTRACT: Converts Beats Per Minute to note values in milliseconds.
# Useful when needing to calculate delay times, attack / release times of compressors, reverb lengths etc.

use DDG::Goodie;

zci answer_type => "bpmto_ms";
zci is_cached   => 1;

name "BPM (beats per minute) to ms (milliseconds) converter";
description "Takes a tempo as BPM (beats per minute), eg. 120, and returns the corresponding note values as milliseconds.";
primary_example_queries "120 bpm to ms";
category "conversions";
topics "music";
code_url "https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/BPMToMs.pm";
attribution github => ["https://github.com/stefolof", "stefolof"],
            twitter => "stefolof";

triggers end => "bpm to ms";

handle remainder => sub {
    return unless $_; # Guard against "no answer"
    return unless $_ =~ /^\d+$/i; # Only integer values accepted
    
    return html => "<div class=\"record\">
                    <table style=\"border-spacing: 10px; border-collapse: separate;\" class=\"record__body\">
                        <tr class=\"record__row record__highlight\">
                            <td>Whole Note:</td><td>" . 240000 / $_ . " ms</td>
                            <td>Triplet:</td><td>" . 160000 / $_ . " ms</td>
                            <td>Dotted:</td><td>" . 360000 / $_ . " ms</td>
                        </tr>
                        <tr class=\"record__row record__highlight\">
                            <td>Half Note:</td><td>" . 120000 / $_ . " ms</td>
                            <td>Triplet:</td><td>" . 80000 / $_ . " ms</td>
                            <td>Dotted:</td><td>" . 180000 / $_ . " ms</td>
                        </tr>
                        <tr class=\"record__row record__highlight\">
                            <td>Quarter Note:</td><td>" . 60000 / $_ . " ms</td>
                            <td>Triplet:</td><td>" . 40000 / $_ . " ms</td>
                            <td>Dotted:</td><td>" . 90000 / $_ . " ms</td>
                        </tr>
                        <tr class=\"record__row record__highlight\">
                            <td>1/8 Note:</td><td>" . 30000 / $_ . " ms</td>
                            <td>Triplet:</td><td>" . 20000 / $_ . " ms</td>
                            <td>Dotted:</td><td>" . 45000 / $_ . " ms</td>
                        </tr>
                        <tr class=\"record__row record__highlight\">
                            <td>1/16 Note:</td><td>" . 15000 / $_ . " ms</td>
                            <td>Triplet:</td><td>" . 10000 / $_ . " ms</td>
                            <td>Dotted:</td><td>" . 22500 / $_ . " ms</td>
                        </tr>
                        <tr class=\"record__row record__highlight\">
{'fraction_non_alphanumeric': 0.16118769883351008, 'fraction_numerical': 0.03340402969247084, 'mean_word_length': 1.4755030621172354, 'pattern_counts': {'":': 0, '<': 149, '<?xml version=': 0, '>': 164, 'https://': 4, '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': '7117447', 'n_tokens_mistral': 1831, 'n_tokens_neox': 1632, 'n_words': 371}