コード例 #1
0
def runfromfft_graph(f, psd):
    peaklist = aa.peak_map(psd)
    peaksdex = aa.peak_assign(peaklist)
    output = guesswork(f, psd, peaklist, peaksdex)
    ax = gf.init_image(ylabel='POWER')
    gf.std_graph(ax, output[:, 0], output[:, 1])
    ax2 = gf.get_twinx(ax)
    gf.std_graph(ax2, output[:, 0], output[:, 2], c='r')
    plt.show()
    print(aa.print_identify(aa.identify(output)))
コード例 #2
0
ファイル: analyze.py プロジェクト: sayanmndl21/sound-analyzer
def peak_impose(ax, frequency, peaklist):
    x = list(range(len(peaklist)))
    ax2 = ax.twinx()
    gf.std_graph(ax2, frequency[x], peaklist, c='b')
    peaksdex = peak_assign(peaklist)
    gf.button_grapher(ax2, frequency, peaksdex, peaklist)
コード例 #3
0
ファイル: data.py プロジェクト: sayanmndl21/sound-analyzer
def plotdots(ax, i, detect):
    colored = 'r'
    if detect:
        colored = 'b'
    gf.std_graph(ax, [i, i + 1], [0, 0], c=colored, lw=3)
コード例 #4
0
ファイル: data.py プロジェクト: sayanmndl21/sound-analyzer
ax = gf.init_image(xlabel='Intervals', ylabel='Power Rating', title='')
ax.set_ylim(-10, 200)
i = 0
tot = 0
for each in result:
    print(each)
    print(aa.detect(each))
    if aa.detect(each):
        tot += 1
    plotdots(ax, i, aa.detect(each))
    i += 1
print(tot)
gf.std_graph(ax,
             np.arange(len(result)),
             result[:, 2] - 120,
             c='g',
             label='Power')
# ax.axvspan(4, 21, alpha=0.5, color='b')
# ax.axvspan(30, 51, alpha=0.5, color='b')
# ax.axvspan(65, 72, alpha=0.5, color='b')
# ax.axvspan(3, 16, alpha=0.5, color='b')
# ax.axvspan(33, 54, alpha=0.5, color='b')
# ax.axvspan(11, 36, alpha=0.5, color='b')
# ax.axvspan(55, 72, alpha=0.5, color='b')
ax2 = gf.get_twinx(ax, ylabel='Matches')
gf.std_graph(ax2, np.arange(len(result)), result[:, 3], c='r', label='Matches')
ax.legend(loc=2)
ax2.legend(loc=1)
gf.show()
コード例 #5
0
    background = sys.argv[1]
    audio = sys.argv[2]
    fs = 44100
    if len(sys.argv) > 3:
        fs = int(sys.argv[3])

    # Build image
    background = aa.load_npy(background)
    audio = aa.load_npy(audio)
    ax = gf.init_image()

    # Set double scale
    ax2 = ax.twinx()

    # Run spectrum analysis
    freq, curve = aa.spectrum(background, fs)
    _, bluecurve = aa.spectrum(audio, fs)
    # bluecurve = bluecurve * curve[2]/bluecurve[2]
    snratio = bluecurve / curve

    # Graph ax
    gf.semi_graph(ax, freq, curve, label='background')
    gf.semi_graph(ax, freq, bluecurve, 'b', 'recording')
    gf.std_graph(ax2, freq, snratio, label='S/N ratio')
    maxdex = aa.max_range(bluecurve, 10)
    print_maxdex(freq, snratio, maxdex)
    gf.pin_grapher(ax, freq, maxdex, curve, bluecurve)
    ax.legend(loc=2)
    ax2.legend(loc=0)
    plt.show()
コード例 #6
0
def runfromfft_graph(f, psd):
    peaklist = aa.peak_map(psd)
    peaksdex = aa.peak_assign(peaklist)
    output = guesswork(f, psd, peaklist, peaksdex)
    ax = gf.init_image(ylabel='POWER')
    gf.std_graph(ax, output[:, 0], output[:, 1])
    ax2 = gf.get_twinx(ax)
    gf.std_graph(ax2, output[:, 0], output[:, 2], c='r')
    plt.show()
    print(aa.print_identify(aa.identify(output)))


if __name__ == '__main__':
    filename = sys.argv[1]
    parts = 1
    if len(sys.argv) > 2:
        parts = int(sys.argv[2])
    au = aa.load_npy(filename)
    # Get the shorter audio pack
    audiolist = np.array_split(au, parts)
    for audio in audiolist:
        output = run(audio)
        # for each in output:
        #     print(each)
        ax = gf.init_image(ylabel='POWER')
        gf.std_graph(ax, output[:, 0], output[:, 1] - 120)
        ax2 = gf.get_twinx(ax)
        gf.std_graph(ax2, output[:, 0], output[:, 2], c='r')
        plt.show()