音高不等于频率

中学以来,我粗浅的音乐知识一直告诉我,不同的音高其实就是不同的频率。具体地说,乐音的基频决定了它的音高,泛音的组合关系决定了它的音色。

但是,实际情况可能要复杂的多。在尝试用Matlab作曲时我发现,用频率组合的思路,很难产生真实的乐器发出的声音。这也是为什么第二部分一直难产,我没拿准频率组合的思路最终可以做到什么程度。

这几天在看维基的时候才发现,根本的问题在于,音高并不等同于频率。频率是一个可测量的物理指标,而音高是人类大脑对于频率组合的总体解读。这个解读跟乐音的基频有很大关系,但是不绝对。

这么说可能很抽象,还是简单看一个例子(来自维基百科):

这一段音乐的独特之处在于,听上去,音高在1分钟时间内一直在降低,而实际上音乐是重复的(都不用分析频率)。

频谱图在这里,这里的频率是线性坐标:

更多的信息请查看:

https://en.wikipedia.org/wiki/Shepard_tone

Advantages of Chinese Teaching

OK, I use this title just to bring attention.

After watching all 3 episodes of the BBC documentary, Are our kids tough enough, Chinese School,  in my opinion, there is one aspect of British kids that really needs to improve: coping with competition and failure.

When British kids were in the PE class, they were very upset that they might fail. Philippa actually sobbed on not passing one item. And she said:

“I just don’t think comparing yourself to others is a good, healthy life style.”

vlcsnap-2015-08-19-23h22m51s591

Philippa is not alone. In the 1st episode, we saw another boy sobbed during PE class.

Well, I have to agree with Philippa that it is not a healthy life style. But competition is part of life. Ranking students all the time with different measures is of course too much, but exposing them to a certain dose of competition is essential to their development. To Philippa, I’d say it’s equally not healthy if young people are so scared of competition that they sob on a failure in just one PE preparation. I don’t want my daughter to be so fragile.

So this is the advantage of Chinese teaching. Put all the drawbacks aside, this is probably one thing Britain should learn from Chinese teaching: To get the kids used to competition.

教学方式差异还是文化差异

BBC的纪录片“Are out Kids Tough Enough? Chinese School”,中文名“我们的孩子足够坚强吗?中式学校”一下子就火了朋友圈了。上网一搜,各种评论铺天盖地。赶快花了两个小时找到看看,免得落后时代太远。下面的我的感想和评论:

首先我要说,其实很多网友的评论发挥的太远了,跟这个节目本身关系不大。其次,从节目中我看到的是语言障碍和文化冲突,教育理念和方法的差异并为充分展现,被展现的部分也主要是文化差异的衍生物。

实验设置

没注意看这活动是谁组织的。我觉得主意非常好,不同文化的师生交流可以成为一个观察文化差异的绝好窗口。但是要说对比中式教育和英式教育的优劣,这题目就太大了。

首先,无论是中式教育还是英式教育,都是不断变化的。节目中的五位老师很难说有代表性。要参加节目,总要英语过得去,又要过去教学记录好,最终的结果很可能是在教学方面不见得能真正代表中式教育,在语言方面不见得能理解西方文化。在节目中我看到的就恰好就是这样。

教学是师生之间的互动,语言障碍和文化差异不可忽视。从我最早在报纸上看到外教抱怨中国学生不参与课堂互动,到现在该有20多年了。中国老师去英国当然也会遇到类似的困境。考虑到这一点,在实验安排上理应留出一段时间给老师和学生进行磨合适应。

继续阅读教学方式差异还是文化差异

It’s about language and culture, dude

中文无废话版在这里

It came to me as a complete surprise that the BBC documentary Are Our Kids Tough Enough? Chinese School got so much attention, and the debate over which is better, the Chinese way or the British way, actually got so heated up.

So I just spent 2 hours watching it on Youtube and here’s what I think.

First of all, I’d say the heated debate and all the furious comments on which way of teaching is better are mostly not based on the video itself. Because what the documentary shows is not a meaningful comparison. All the Chinese teachers simply failed miserably in managing their classes from the very beginning, due largely to, in my humble opinion, cultural conflict and language barrier. So I’ll base my comment on the program and maybe comment on the debate over this program in a separate post.

The Experiment

I don’t know who organized this. I think it’s a fantastic idea in terms of cultural exchange. But if the goal is to compare the Chinese way of teaching to the British way of teaching,  it cannot be taken seriously.

Teaching involves extensive interaction between the teachers and the students. Language barrier and cultural difference cannot be overlooked. Stories of foreign teachers got frustrated in Chinese classes because Chinese students were inactive have been around since 20+ years now. Why should we expect the Chinese teachers not to be shocked in a British school? This cultural shock should be expected and extra time should be planned for both the teachers and the students to adapt.

继续阅读It’s about language and culture, dude

Skin color is an illusion from Nina Jablonski

This talk is kind of special. The content has nothing really new to me, except the fact that Darwin had actually concluded that skin color has nothing to do with climate. However, Ms. Nina Jablonski delivered it in such passion and power that you feel the urge of immediate action.

You can tell from the fluent flow of long sentences that this is for sure a carefully prepared talk. But no passion was lost in the preparation. Outstanding!

setting up OTRS 4

I was asked to evaluate some ticket tracking tools and OTRS came back into my mind. The following steps outline the procedure to have OTRS correctly installed on CentOS 7:

  1. LAMP stack; You probably already have it. And on your system you might have MariaDB instead of MySQL. That doesn’t matter.
  2. Install and configure Postfix and Dovecot.
  3. Make sure the following configuration for MySQL has been taken care of, especially for the 3rd line:
            max_allowed_packet=50M
            query_cache_size=32M
            innodb_log_file_size=1073741824
  4. Install some additional perl modules from EPEL repository.
  5. Install OTRS from command line:
    yum install --nogpgcheck http://ftp.otrs.org/pub/otrs//RPMS/rhel/7/otrs-4.0.11-01.noarch.rpm
  6. Once the installation is done, continue with the web installer from:
    http://<your host ip>/otrs/installer.pl
  7. Simply following the wizard and then you should have a working OTRS installation.
  8. Login to OTRS using super admin account. Go to “Admin->System Administration->Package Manager” and install additional packages. Typically you’d want have OTRS:ITSM and other related packages.

Up to here, you have a working installation. In order to work with OTRS, now you have to configure all the queues, agents, customers, groups, templetes, etc. Have fun!

通过截获gettext调用来修改WordPress的部分翻译

这是上一篇文章的中文版。

WordPress网站的页面底端通常有一句话,英文原文是“Proudly Powered by WordPress”,链接到WordPress网站。这句话当前的官方翻译是,“自豪地采用WordPress”。我个人认为,这个翻译是蹩脚的字面翻译,中国人不大会用这种语言致谢。更好的翻译应该是“低调地使用WordPress”。

但是要修改这一句话还不太容易,比较了多种方法之后,我采用了如下方法:

  1. 创建一个child theme。
  2. 在child theme的functions.php中加入如下代码:

[code language=”php”]
function change_attribute_line( $translated_text, $text, $domain ) {
        switch ( $text ) {
            case ‘Proudly powered by %s’ :
               $translated_text = __( ‘低调地使用%s’);
           break;
}
return $translated_text;
}
add_filter(‘gettext’, ‘change_attribute_line’,20,3);
[/code]
就可以了。

代码基本没有需要解释的地方。我在此处搜索$test而不是$translated_text仅仅是因为我觉得匹配英文字符串可能更快一些。

值得注意的是,此处的字符串中仍然包含有占位符”%s”。这就是说,gettext和它的filter是在占位符”%s”被替换之前调用的。

如果我搜索替换后的字符串“Proudly powered by WordPress”,是搜索不到的。我刚开始不明白(不仅WordPress文档没有指出这一点,网上好像也没有人遇到这个问题)所以在此花了很长时间。希望看到帖子的同学们可以节省一些时间。

Replacing WordPress translation by hooking to gettext

In a typical WordPress website, you see this line in the page footer:

“Proudly powered by WordPress”

This line links to WordPress website. The official Chinese translation of this line is:

“自豪地采用WordPress”

I’m using WordPress in several of my websites and I found it’s annoying: It’s a word to word translation and it’s simply not what we Chinese would say when we want to attribute something to someone. After some thinking, I think the appropriate translation should be:

低调地使用WordPress

“采用”emphasis the choosing of WordPress, “使用”emphasis the fact we are using WordPress right now.

The message is clear and typical Chinese: I’m a humble webmaster. All the glories go to WordPress.

So I set out to change the translation. It turned out to be rather complicated, but here’s how I finally accomplished it:

  1. Create a child theme of your current theme, because you’ll have to rewrite its logic and you don’t want your effort to be overwritten by an upgrade of that theme. The procedure of creating a child theme can be found here.
  2. In your function.php file, add the following lines:

[code language=”php”]
function change_attribute_line( $translated_text, $text, $domain ) {
        switch ( $text ) {
            case ‘Proudly powered by %s’ :
               $translated_text = __( ‘低调地采用%s’);
           break;
}
return $translated_text;
}
add_filter(‘gettext’, ‘change_attribute_line’,20,3);
[/code]

That’s it.

Notice that I search for $text instead of $translated_text. You can also search for $translated_text. That would be:
[code language=”php”]
        switch ( $translated_text ) {
            case ‘自豪地采用%s’ :
               $translated_text = __( ‘低调地使用%s’);
           break;
}
return $translated_text;
[/code]
I search for $text because I assume (I’m not sure) search for non-unicode string will be faster.

It’s worth noting that both strings have placeholders in it. Initially I was trying to search the whole string, “Proudly powered by WordPress” or “自豪地采用WordPress” and failed. The fact that the above code works tells us, gettext() and its filters are called before the placeholders get replaced. I spent a lot of time figuring this out. It’s not mentioned in the document, nor did anyone post this on the web. This is actually the key reason why I write this post. Someone from WordPress should update the document.

小人书!

小摊上看到,挑了一些古代人物和故事的。看上去挺新,但是印刷质量一般,疑心是盗印的。不过重点是内容不错,尤其是文字自然平实,简练流畅。给小朋友看再好不过。贴一下照片:

唐伯虎:上海人民美术出版社
文:夏振亚
图:王义秋

Tang Bohu
cover image of story book “Tang Bohu”.

满江红:人民美术出版社
文:范钧宏 吕瑞明 任梅
图:墨浪

Man Jiang Hong
Cover page of storybook “Man Jiang Hong”

八仙过海:中国旅游出版社
文:李源 任宝贤
图:韩亚洲 范世评

Ba Xie Guo Hai
Cover page of story book “Ba Xie Guo Hai”

海瑞罢官:上海人民美术出版社
文:吴晗 李大发
图:黄全昌

20150723_173425

陆游:上海人民美术出版社

继续阅读小人书!

中国古诗文

正在考虑建立一个中国古诗文网站,目的是给孩子看,类似于《唐诗三百首》和《古文观止》,内容也多从其中来。特色在于:

  • 在内容上,以原文为本。不要译文,基本没有注释。
  • 在布局上,以内容为主,去除一切干扰因素。要求干净,大方。
  • 各古诗文名家作者就是blog作者,既直观有趣,又方便组织。

需要做的工作:

  1. 开发批量插入作者的功能——已完成;
  2. 开发批量插入帖子的功能——已完成;
  3. 建立分类目录:需要专业人员帮助。
  4. 开发新的数据结构以存储传统计时方式:朝代,年号,年号纪年,公元纪年,季节,时令,时辰。
  5. 扩展帖子属性,其中帖子发表时间采用新的数据结构。
  6. 扩展作者属性,其中作者生卒时间采用新的数据结构。
  7. 修改界面,使帖子能够显示传统计时(年号,天干地支)。

当前状态见这里:http://gushiwen.genglinxiao.com/