2012年9月15日 星期六

BASSMIDI 讓DOSBox發出更棒的MIDI音樂!

某次在 http://www.gamebase.com.tw/forum/30032骨灰集散地上面看到安裝外部MIDI Driver可以讓Dosbox模擬 Ronald MT-32,拜讀之後我很興奮的趕快去嘗試,遊戲的聲音真的不一樣了,這是聲霸卡所不能比擬的好聲音啊~~~聽到美少女夢工廠悠揚的音樂,銀河英雄傳說3高昂壯闊的交響樂,深深改變了玩Game感覺,這個Driver甚至連以前的FC上面的音樂也變得格外好聽。

 但是奇怪怎麼還是有些 Midi 沒有聲音啊~~~~ 就心血來潮在網路上找看看有沒有其他的 Midi Driver,就發現了一個萬用型MIDI模擬器BASSMIDI,已掛載不同SoundFont模擬不同MIDI音源器的效果.網址在下面,網站裡面有提供不同MIDI音效卡的SoundFont,其實我不知道如何確切描述SoundFont是甚麼東西,不過它應該是一個紀錄不同樂器所發出的聲音的檔案吧~

Bassmidi 的網址如下 http://www.mudlord.info/bassmididrv/BASSMIDI_Driver_Installation_and_Configuration.htm

Bassmidi的安裝方式
1. 下載 Bassmidi 的安裝檔案並解開安裝 http://www.mudlord.info/bassmididrv/bassmididrv.exe

2. 下載 SoundFont ,並且解開放到適當的位置 在此推薦幾個不錯的

SoundFont "Roland SC-55 v1.1 http://www.mediafire.com/?a6qn1tc811b2ce1

OPL-3 FM 128M" Sound Blaster 16 FM Synthesis SoundFont http://woolyss.com/chipmusic/chipmusic-soundfonts/OPL-3_FM_128M.zip

Gravis Ultrasound Classic Patch Set v1.6b http://www.rarek.ceron.pl/gus.htm

3. 重新開機,然後啟動 Bassmidi 的控制台 BASSMIDI Driver Configuration Utility 4

. 新增 SoundFont file,注意一下最底層的SoundFont會被優先使用喔!,然後就打開你的Dosbox好好享受提供Midi音樂的遊戲吧

附註:

對於在Windows上面模擬 Ronald MT-32有興趣的玩家可以參考下面這個網址: http://www.dearhoney.idv.tw/?p=243
MT-32的ROM可以從海盜灣上面抓取, Driver的由下面這個網址去下載http://sourceforge.net/projects/munt

另外再 Windows7上面的玩家,如果要改變系統預設的Midi Driver請到http://akkordwechsel.de/15-windows-vista-und-der-midi-mapper/ 去下載 Putzlowitschs Vista MIDI-Mapper Control-Panel Version 0.93 就可以直更改 系統預設的 Midi Driver

附註:

OPL-3 FM 128M 下載後解開的格式為 sfpack 
sfArk ( sfpack ) 的格式 要利用 sfpack 這隻程式去轉成 sf2 
轉換程式的網址如下

2012年3月13日 星期二

Python Script sample and resample with different x range

#!/usr/bin/python
import random
# by wjy
#define variable
samples_time=5000
samples_start=1
samples_end=1023
samples=[]
samples_count=range(samples_end+1)

resamples_base_q=[0.05,0.1,0.15,0.2,0.25,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1]
resamples_base_count=range(len(resamples_base_q))
resamples_count=range(len(resamples_base_count))
print '__name__ = ', __name__

def generate_samples():
"generate the samples"
count=samples_time
while count > 0 :
tmp=random.normalvariate(samples_end/2, samples_end/6)
samples.append(int(tmp))
#samples.append(int(random.uniform(samples_start,samples_end)))
count=count-1
return;

def generate_statistics():
"count the samples"
print max(samples)
count=0
while count times=samples.count(count)
samples_count[count]=0
if times>0:
samples_count[count]=times
#print count," appear ", times, "times"
count=count+1
return

def func1():
"func1"
return;

def write_sample_counts_to_file():
fo = open ("sample.counts","w")
count=0
while count line="%s\t%s\n" %(count,samples_count[count])
#fo.write(count,"\t",samples_count[count])
fo.write(line)
count=count+1
fo.close()
return

def generate_resamples_count():
"generate resamples count"
count=0
# generate resamples base count
while count resamples_base_count[count]= samples_end* resamples_base_q[count]
resamples_count[count]=0
count=count+1

# generate resamples count
count=0
while count count2=0

while count2 < len(resamples_base_count):
if count < resamples_base_count[count2]:
#print count,"<",resamples_base_count[count2]
resamples_count[count2]=resamples_count[count2]+samples_count[count]
break
count2=count2+1

count=count+1
return

#=======================================================
def write_resamples_counts_to_file():
fo = open ("resamples.counts","w")
fo2 = open ("resamples.counts2","w")
count=0
while count line="%s\t%s\n" %(resamples_base_count[count],resamples_count[count])
#fo.write(count,"\t",samples_count[count])
fo.write(line)
line="%s\t%s\n" %(count,resamples_count[count])
fo2.write(line)
count=count+1
fo.close()
fo2.close()
return
#=======================================================
def main():
generate_samples()
generate_statistics()
write_sample_counts_to_file()
generate_resamples_count()
write_resamples_counts_to_file()
#print samples
#samples_count=range(101)
#samples_count[100]=1
#print samples_count
#print "reample_base",resamples_base_count
#print "reample_count",resamples_count
print "Hello World Python"
return 0

if __name__ == "__main__":
main()

Gnuplot note

Gnuplot note

set xrange[0:12] 設定 x 軸 range
set xrange[0:1024]
set xlabel "x" 設定 label
set ylabel "y" 設定 label
set term x11 0 第一個視窗
plot 在第一個視窗繪圖
set term x11 1 第二個視窗
plot 在第二個視窗繪圖
set term x11 2
plot 在第三個視窗繪圖

1:2 = column 用 white space 隔開
plot "file" using 1:2 title "f1" with boxes / impulses


set multiplot 同一個視窗同時繪圖 很多個檔案

set term x11 0
plot sin(x)
set term x11 1
plot cos(x)

2011年8月21日 星期日

Tuscany 2.0 beta3 建立多個 Node 在同一個 SCA Domain 的呼叫方式

The code snippet :

import org.apache.tuscany.sca.node.NodeFactory;
import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
import org.apache.tuscany.sca.node.configuration.impl.NodeConfigurationImpl;

String ContributionPath;
org.apache.tuscany.sca.node.Node nodeInstance = null;
NodeConfiguration nodeCof = new NodeConfigurationImpl();
nodeCof.addContribution( ContributionName , ContributionPath );

NodeFactory.getInstance().setAutoDestroy(false);
nodeInstance = NodeFactory.getInstance().createNode( nodeCof );

nodeInstance.start();

Reference site :

http://mail-archives.apache.org/mod_mbox/tuscany-commits/201104.mbox/%3C20110427102304.31D60238890A@eris.apache.org%3E

How to handle SCA the error Business Interface in not compatible on OSGi

當我打包整個 Tuscany Runtime 成 OSGi bundle 並且安裝到 glassfish 上面時

其他 OSGi bundle 使用 Tuscany Runtime bundle 時偶而會發出

Business interface is XXX not compatible

這是 bundle 在 MANIFEST.MF 中 Import-Package 不完全所至

所以最快的解決辦法 就是把 Tuscany Runtime Bundle 所 Export-Package 全部變成
該 SCA-OSGi bundle 的 Import-Package 就可以解決這個問題

啟動 Glassfish OSGI Telnet 服務

啟動 Glassfish 的 OSGI telent 服務

修改

$GLASSFISH/osgi/felix/conf/config.properties

optionals.bundles = ....
$(com.sun.aas.installRootURI}modules/org.apache.felix.shell.jar \
$(com.sun.aas.installRootURI}modules/org.apache.felix.shell.remote.jar \

telnet localhost 6666

就可以進入 remote console 管理 bundles

2011年5月3日 星期二

確認 android Resource layout 內的 view 是否存在

Android 的 project 編譯的時候會產生對應的 R.java ,
layout.xml 中的 view 物件會產生對應的 id ,
所以可以裡用 Activity.getViewById 取得對應的 View 物件

但是如何確認 R.id 內 有沒有要的 view 呢??

利用 Java Reflection 機制可以達到這個功能
首先讓我們先回憶一下 id 如何產生
下面 宣告一個 Button 在 layout.xml 當中,


放到 eclipse 編譯後會產生對應的 R.java
幸運的是 變數名稱等於 上述 分配的 id 名稱
只要 id 名稱不變 就可以確認該 View 是否存在於 layout.xml 當中
因此搭配下列的程式碼

Class cls = R.id.class;
Field field = null;
int value = 0;

try {
field = cls.getField("button_testSSL");
if ( field == null ) {
return ;
}
} catch ( Exception e ) {
e.printStackTrace();
}
try {
value = field.getInt(null);
} catch ( Exception e ) {
e.printStackTrace();
}

field 等於 null 表示該物件不存在, 如果存在就利用 field.getInt 取得該 View id

之後利用 getViewById(value) 就可以取得該物件了

這樣一來就不用每次換UI都要註解掉一些不用的函數, 可以省去很多功夫