ios音乐播放时,怎么可以获取到当前音乐的音波频率大小

ios音乐播放时,怎么可以获取到当前音乐的音波频率大小,第1张

我也感觉没多大用处,纯粹好玩。有的可视化效果是重复的,而有的是与所播放的歌曲相关的。比如说当出现一个重音,音波的变化就大。照这样看,这些图形可以指示播放歌曲的某一时刻的某一物理性质(声强或频率,再具体的不知道)。

这个和cpu没有任何关系,我用android 系统的三星 i5700 ,拷贝过24G的导航软件,大约40-60分钟。这个没有准确时间,和文件大小及数量有关系,也和sd卡有很大关系,也和电脑的运行状况有关系,我个人觉得你大约需要15-2小时左右吧

 Device Year Class 的主要功能是根据 CPU核数、时钟频率 以及 内存大小 对设备进行分级。代码很简单,只包含两个类:DeviceInfo-> 获取设备参数,YearClass-> 根据参数进行分级。下表是 Facebook 公司提供的分级标准,其中Year栏表示分级结果。Year Cores Clock RAM2008 1 528MHz 192MB2009 n/a 600MHz 290MB2010 n/a 10GHz 512MB2011 2 12GHz 1GB2012 4 15GHz 15GB2013 n/a 20GHz 2GB2014 n/a >2GHz >2GB关于输出年份的计算方法可以参考源码,本文只把一些比较常用的功能抽取出来做一个简要介绍。获取 CPU 核数我们都知道,Linux 中的设备都是以文件的形式存在,CPU 也不例外,因此 CPU 的文件个数就等价与核数。Android 的 CPU 设备文件位于/sys/devices/system/cpu/目录,文件名的的格式为cpu\d+。12345678910root@generic_x86_64:/sys/devices/system/cpu # ls <b>cpu0</b> cpufreqcpuidlekernel_maxmodaliasofflineonlinepossiblepowerpresentuevent统计一下文件个数便可以获得 CPU 核数。1234567891011121314151617181920212223242526272829303132333435public static int getNumberOfCPUCores() {if (BuildVERSIONSDK_INT <= BuildVERSION_CODESGINGERBREAD_MR1) {// Gingerbread doesn't support giving a single application access to both cores, but a// handful of devices (Atrix 4G and Droid X2 for example) were released with a dual-core// chipset and Gingerbread; that can let an app in the background run without impacting// the foreground application But for our purposes, it makes them single corereturn 1;}int cores;try {cores = new File("/sys/devices/system/cpu/")listFiles(CPU_FILTER)length;} catch (SecurityException e) {cores = DEVICEINFO_UNKNOWN;} catch (NullPointerException e) {cores = DEVICEINFO_UNKNOWN;}return cores;}private static final FileFilter CPU_FILTER = new FileFilter() {@Overridepublic boolean accept(File pathname) {String path = pathnamegetName();//regex is slow, so checking char by charif (pathstartsWith("cpu")) {for (int i = 3; i < pathlength(); i++) {if (pathcharAt(i) < '0' pathcharAt(i) > '9') {return false;}}return true;}return false;}};回到顶部获取时钟频率获取时钟频率需要读取系统文件 -/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq或者/proc/cpuinfo。我的 Android 模拟器中并没有cpuinfo_max_freq文件,因此只能读取/proc/cpuinfo。/proc/cpuinfo包含了很多 cpu 数据。processor : 0vendor_id : GenuineIntelcpu family : 6model : 70model name : Intel(R) Core(TM) i7-4770HQ CPU @ 220GHzstepping : 1cpu MHz : 0000cache size : 1024 KBfdiv_bug : nohlt_bug : nof00f_bug : nocoma_bug : nofpu : yesfpu_exception : yescpuid level : 4wp : yes代码如下:public static int getCPUMaxFreqKHz() {int maxFreq = DEVICEINFO_UNKNOWN;try {for (int i = 0; i < getNumberOfCPUCores(); i++) {String filename ="/sys/devices/system/cpu/cpu" + i + "/cpufreq/cpuinfo_max_freq";File cpuInfoMaxFreqFile = new File(filename);if (cpuInfoMaxFreqFileexists()) {byte[] buffer = new byte[128];FileInputStream stream = new FileInputStream(cpuInfoMaxFreqFile);try {streamread(buffer);int endIndex = 0;//Trim the first number out of the byte bufferwhile (buffer[endIndex] >= '0' && buffer[endIndex] <= '9'&& endIndex < bufferlength) endIndex++;String str = new String(buffer, 0, endIndex);Integer freqBound = IntegerparseInt(str);if (freqBound > maxFreq) maxFreq = freqBound;} catch (NumberFormatException e) {//Fall through and use /proc/cpuinfo} finally {streamclose();}}}if (maxFreq == DEVICEINFO_UNKNOWN) {FileInputStream stream = new FileInputStream("/proc/cpuinfo");try {int freqBound = parseFileForValue("cpu MHz", stream);freqBound = 1000; //MHz -> kHzif (freqBound > maxFreq) maxFreq = freqBound;} finally {streamclose();}}} catch (IOException e) {maxFreq = DEVICEINFO_UNKNOWN; //Fall through and return unknown}return maxFreq;}回到顶部获取内存大小如果 SDK 版本大于等于JELLY_BEAN,可以通过ActivityManager来获取内从大小。 ActivityManagerMemoryInfo memInfo = new ActivityManagerMemoryInfo();ActivityManager am = (ActivityManager) cgetSystemService(ContextACTIVITY_SERVICE);amgetMemoryInfo(memInfo);如果版本低于JELLY_BEAN,则只能读取系统文件了。FileInputStream stream = new FileInputStream("/proc/meminfo");totalMem = parseFileForValue("MemTotal", stream);完整代码如下: @TargetApi(BuildVERSION_CODESJELLY_BEAN)public static long getTotalMemory(Context c) {// memInfototalMem not supported in pre-Jelly Bean APIsif (BuildVERSIONSDK_INT >= BuildVERSION_CODESJELLY_BEAN) {ActivityManagerMemoryInfo memInfo = new ActivityManagerMemoryInfo();ActivityManager am = (ActivityManager) cgetSystemService(ContextACTIVITY_SERVICE);amgetMemoryInfo(memInfo);if (memInfo != null) {return memInfototalMem;} else {return DEVICEINFO_UNKNOWN;}} else {long totalMem = DEVICEINFO_UNKNOWN;try {FileInputStream stream = new FileInputStream("/proc/meminfo");try {totalMem = parseFileForValue("MemTotal", stream);totalMem = 1024;} finally {streamclose();}} catch (IOException e) {}return totalMem;}}

以上就是关于ios音乐播放时,怎么可以获取到当前音乐的音波频率大小全部的内容,包括:ios音乐播放时,怎么可以获取到当前音乐的音波频率大小、android 平台下,手机读取Micro SD card 音乐文件的速度怎么衡量,现在有一张4G 的卡,里面有700首歌曲。、如何获取 Android 设备的CPU核数,时钟频率以及内存大小等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/9542365.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-29
下一篇 2023-04-29

发表评论

登录后才能评论

评论列表(0条)

保存