{"id":39846,"date":"2023-02-04T13:51:20","date_gmt":"2023-02-04T05:51:20","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=39846"},"modified":"2023-02-04T13:51:20","modified_gmt":"2023-02-04T05:51:20","slug":"how-octave-audio","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/how-octave-audio.html","title":{"rendered":"\u4f7f\u7528Octave\u97f3\u9891\u5904\u7406\uff08\u4e00\uff09\uff1a\u5bf9\u6587\u4ef6\u8fdb\u884c\u8bfb\u5199\u64cd\u4f5c"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nOctave \u662f\u4e00\u4e2a Linux \u4e0a\u7c7b\u4f3c\u4e8e Matlab \u7684\u8f6f\u4ef6\uff0c\u5b83\u62e5\u6709\u6570\u91cf\u4f17\u591a\u7684\u51fd\u6570\u548c\u547d\u4ee4\uff0c\u652f\u6301\u58f0\u97f3\u91c7\u96c6\u3001\u8bb0\u5f55\u3001\u56de\u653e\u4ee5\u53ca\u97f3\u9891\u4fe1\u53f7\u7684\u6570\u5b57\u5316\u5904\u7406\uff0c\u7528\u4e8e\u5a31\u4e50\u5e94\u7528\u3001\u7814\u7a76\u3001\u533b\u5b66\u4ee5\u53ca\u5176\u5b83\u79d1\u5b66\u9886\u57df\u3002\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u4f1a\u5728 Ubuntu \u4e0a\u4f7f\u7528 Octave \u7684 4.0.0 \u7248\u672c\u8bfb\u53d6\u97f3\u9891\u6587\u4ef6\uff0c\u7136\u540e\u901a\u8fc7\u751f\u6210\u4fe1\u53f7\u5e76\u4e14\u64ad\u653e\u6765\u6a21\u4eff\u5728\u5404\u79cd\u60c5\u51b5\u4e0b\u5bf9\u97f3\u9891\u4fe1\u53f7\u7684\u4f7f\u7528\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u73af\u5883\u51c6\u5907<\/strong><\/div>\n

\u9996\u5148\u662f\u5b89\u88c5 octave\uff0c\u5728 Ubuntu \u7ec8\u7aef\u8fd0\u884c\u4e0b\u9762\u7684\u547d\u4ee4\u6dfb\u52a0 Octave PPA\uff0c\u7136\u540e\u5b89\u88c5 Octave \u3002<\/p>\n

sudo apt-add-repository ppa:octave\/stable\r\nsudo apt-get update\r\nsudo apt-get install octave<\/pre>\n
\u6b65\u9aa41\uff1a\u6253\u5f00 Octave<\/strong><\/div>\n

\u5728\u8fd9\u4e00\u6b65\u4e2d\u6211\u4eec\u5355\u51fb\u8f6f\u4ef6\u56fe\u6807\u6253\u5f00 Octave\uff0c\u53ef\u4ee5\u901a\u8fc7\u5355\u51fb\u4e0b\u62c9\u5f0f\u6309\u94ae\u9009\u62e9\u5de5\u4f5c\u8def\u5f84\u3002<\/p>\n

\"audioinfo01\"<\/p>\n

\u6b65\u9aa42\uff1a\u97f3\u9891\u4fe1\u606f<\/strong><\/div>\n

\u4f7f\u7528audioinfo\u547d\u4ee4\u67e5\u770b\u8981\u5904\u7406\u7684\u97f3\u9891\u6587\u4ef6\u7684\u76f8\u5173\u4fe1\u606f\u3002<\/p>\n

>> info = audioinfo ('testing.ogg')<\/pre>\n

\"audioinfo02\"<\/p>\n

\u6b65\u9aa43\uff1a\u8bfb\u53d6\u97f3\u9891\u6587\u4ef6<\/strong><\/div>\n

\u5728\u672c\u6559\u7a0b\u4e2d\u6211\u4f1a\u4f7f\u7528 ogg \u6587\u4ef6\u6765\u8bfb\u53d6\u8fd9\u79cd\u6587\u4ef6\u7684\u5c5e\u6027\uff0c\u6bd4\u5982\u91c7\u6837\u3001\u97f3\u9891\u7c7b\u578b\uff08stereo \u548c mono\uff09\u3001\u4fe1\u9053\u6570\u91cf\u7b49\u3002\u5fc5\u987b\u58f0\u660e\u7684\u4e00\u70b9\u662f\u6559\u7a0b\u4e2d\u4f7f\u7528\u7684\u6240\u6709\u7684\u547d\u4ee4\u90fd\u662f\u5728 Octave \u7ec8\u7aef\u7a97\u53e3\u4e2d\u6267\u884c\u7684\u3002\u9996\u5148\uff0c\u6211\u4eec\u5fc5\u987b\u8981\u628a\u8fd9\u4e2a ogg \u6587\u4ef6\u8d4b\u7ed9\u4e00\u4e2a\u53d8\u91cf\u3002\u6ce8\u610f\uff1a\u6587\u4ef6\u5fc5\u987b\u5728 Octave \u7684\u5de5\u4f5c\u8def\u5f84\u4e2d\u3002<\/p>\n

>> file='yourfile.ogg'\r\n>> [M, fs] = audioread(file)<\/pre>\n

\u8fd9\u91cc\u7684 M \u662f\u4e00\u4e2a\u4e00\u5217\u6216\u4e24\u5217\u7684\u77e9\u9635\uff0c\u53d6\u51b3\u4e8e\u4fe1\u9053\u7684\u6570\u91cf\uff0cfs \u662f\u91c7\u6837\u7387\u3002<\/p>\n

\"audioinfo03\"
\n\"audioinfo04\"
\n\"audioinfo05\"<\/p>\n

\u4e0b\u9762\u7684\u64cd\u4f5c\u90fd\u53ef\u4ee5\u8bfb\u53d6\u97f3\u9891\u6587\u4ef6\uff1a<\/p>\n

>> [y, fs] = audioread (filename, samples)\r\n\r\n>> [y, fs] = audioread (filename, datatype)\r\n\r\n>> [y, fs] = audioread (filename, samples, datatype)<\/pre>\n

samples \u6307\u5b9a\u5f00\u59cb\u5e27\u548c\u7ed3\u675f\u5e27\uff0cdatatype \u6307\u5b9a\u8fd4\u56de\u7684\u6570\u636e\u7c7b\u578b\u3002\u53ef\u4ee5\u4e3a\u6240\u6709\u53d8\u91cf\u8bbe\u7f6e\u503c\uff1a<\/p>\n

>> samples = [1, fs)\r\n\r\n>> [y, fs] = audioread (filename, samples)<\/pre>\n

\u6570\u636e\u7c7b\u578b\uff1a<\/p>\n

>> [y,Fs] = audioread(filename,'native')<\/pre>\n

\u5982\u679c\u503c\u662f\u201cnative\u201d\uff0c\u90a3\u4e48\u5b83\u7684\u6570\u636e\u7c7b\u578b\u5c31\u4f9d\u6570\u636e\u5728\u97f3\u9891\u6587\u4ef6\u4e2d\u7684\u5b58\u50a8\u60c5\u51b5\u800c\u5b9a\u3002<\/p>\n

\u6b65\u9aa44\uff1a\u97f3\u9891\u6587\u4ef6\u7684\u5199\u64cd\u4f5c<\/strong><\/div>\n

\u65b0\u5efa\u4e00\u4e2a ogg \u6587\u4ef6\uff1a<\/p>\n

\u6211\u4eec\u4f1a\u4ece\u4e00\u4e2a\u4f59\u5f26\u503c\u521b\u5efa\u4e00\u4e2a ogg \u6587\u4ef6\u3002\u91c7\u6837\u7387\u662f\u6bcf\u79d2 44100 \u6b21\uff0c\u8fd9\u4e2a\u6587\u4ef6\u6700\u5c11\u8fdb\u884c 10 \u79d2\u7684\u91c7\u6837\u3002\u4f59\u5f26\u4fe1\u53f7\u7684\u9891\u7387\u662f 440 Hz\u3002<\/p>\n

>> filename='cosine.ogg';\r\n>> fs=44100;\r\n>> t=0:1\/fs:10;\r\n>> w=2*pi*440*t;\r\n>> signal=cos(w);\r\n>> audiowrite(filename, signal, fs);<\/pre>\n

\u8fd9\u5c31\u5728\u5de5\u4f5c\u8def\u5f84\u4e2d\u521b\u5efa\u4e86\u4e00\u4e2a \u2018cosine.ogg\u2019 \u6587\u4ef6\uff0c\u8fd9\u4e2a\u6587\u4ef6\u4e2d\u5305\u542b\u4f59\u5f26\u4fe1\u53f7\u3002<\/p>\n

\"audioinfo06\"<\/p>\n

\u64ad\u653e\u8fd9\u4e2a \u2018cosine.ogg\u2019 \u6587\u4ef6\u5c31\u4f1a\u4ea7\u751f\u4e00\u4e2a 440Hz \u7684 \u97f3\u8c03\uff0c\u8fd9\u4e2a\u97f3\u8c03\u6b63\u597d\u662f\u4e50\u7406\u4e2d\u7684 \u2018A\u2019 \u8c03\u3002\u5982\u679c\u9700\u8981\u67e5\u770b\u4fdd\u5b58\u5728\u6587\u4ef6\u4e2d\u7684\u503c\u5c31\u5fc5\u987b\u4f7f\u7528 \u2018audioread\u2019 \u51fd\u6570\u8bfb\u53d6\u6587\u4ef6\u3002\u5728\u540e\u7eed\u7684\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u4f1a\u770b\u5230\u600e\u6837\u5728\u4e24\u4e2a\u4fe1\u9053\u4e2d\u8bfb\u53d6\u4e00\u4e2a\u97f3\u9891\u6587\u4ef6\u3002<\/p>\n

\u6b65\u9aa45\uff1a\u64ad\u653e\u97f3\u9891\u6587\u4ef6<\/strong><\/div>\n

Octave \u6709\u4e00\u4e2a\u9ed8\u8ba4\u7684\u97f3\u9891\u64ad\u653e\u5668\uff0c\u53ef\u4ee5\u7528\u8fd9\u4e2a\u97f3\u9891\u64ad\u653e\u5668\u8fdb\u884c\u6d4b\u8bd5\u3002\u4f7f\u7528\u4e0b\u9762\u7684\u51fd\u6570\uff1a<\/p>\n

>> [y,fs]=audioread('yourfile.ogg');\r\n>> player=audioplayer(y, fs, 8)\r\n\r\n  scalar structure containing the fields:\r\n\r\n    BitsPerSample =  8\r\n    CurrentSample = 0\r\n    DeviceID = -1\r\n    NumberOfChannels =  1\r\n    Running = off\r\n    SampleRate =  44100\r\n    TotalSamples =  236473\r\n    Tag =\r\n    Type = audioplayer\r\n    UserData = [](0x0)\r\n>> play(player);<\/pre>\n

\u5728\u8fd9\u4e2a\u6559\u7a0b\u7684\u7eed\u7bc7\uff0c\u6211\u4eec\u4f1a\u8fdb\u5165\u97f3\u9891\u5904\u7406\u7684\u9ad8\u7ea7\u7279\u6027\u90e8\u5206\uff0c\u53ef\u80fd\u4f1a\u63a5\u89e6\u5230\u4e00\u4e9b\u79d1\u5b66\u548c\u5546\u4e1a\u5e94\u7528\u4e2d\u7684\u5b9e\u4f8b\u3002<\/p>\n

\n

\u539f\u6587\u6765\u81ea\uff1ahttp:\/\/codecloud.net\/21300.html<\/a><\/p>\n

\u672c\u6587\u5730\u5740\uff1ahttp:\/\/lrxjmw.cn\/how-octave-audio.html<\/a>\u7f16\u8f91\uff1a\u5f20\u632f\u5b87\uff0c\u5ba1\u6838\u5458\uff1a\u51af\u742a<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

\u5bfc\u8bfb Octave \u662f\u4e00\u4e2a Linux \u4e0a\u7c7b\u4f3c\u4e8e Matlab \u7684\u8f6f\u4ef6\uff0c\u5b83\u62e5\u6709\u6570\u91cf\u4f17\u591a\u7684\u51fd\u6570\u548c\u547d\u4ee4\uff0c\u652f\u6301\u58f0\u97f3\u91c7 […]<\/p>\n","protected":false},"author":310,"featured_media":39853,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-39846","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/39846","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/310"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=39846"}],"version-history":[{"count":13,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/39846\/revisions"}],"predecessor-version":[{"id":263588,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/39846\/revisions\/263588"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/39853"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=39846"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=39846"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=39846"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}