sync in demos

如何在demo中合成场景?

from http://scene.org/showforum.php?forum=11&topic=108058
-----------------------------------------------------------------------
I'm skilled in c++/delphi/asm and graphics coding.
But one moment is still unclear: sync in demos.
I suppose that there should be a kind a script containing a timeline, like this

[time] [effect] [params]
....
....

Am I right or not?
How transition beetween scenes is made according to timeline?
And how all this is set up in main loop (we need main loop?)?

So, what is a basic structure of demo? Which parts it contain?

I'll be glad to any help

[Post edited by nofate on Saturday 15 July 2006 - 10:39]

-----------------------------------------------------------------------

Posted by _-_-__ Saturday 15 July 2006 - 10:12 
The main structure of a demo is:

initVideoAndAudioDevices();
buildEffects(); // pre-calculation, allocations
mainLoop();
// in demo making it is allowed to use the OS as a garbage collector ;)
releaseVideoAndAudioDevices()

Sometimes the main loop of a demo is as simple as:

boolean mustQuit = false;
while (!mustQuit) {
const double ms = getCurrentMilliseconds();
const double transition1Ms = 8000.;
const double transition2Ms = 12000.;

if (ms >= 0. && ms < transition1Ms) {
effect1 (ms);
} else if (ms >= transition1Ms && ms < transition2Ms) {
effect2 (ms);
} else if (ms >= transition2Ms && ms < endMs) {
effect3 (ms);
} else if (ms >= endMs) {
mustQuit = true;
}

if (pressedEscape ()) {
mustQuit = true;
}
}

Now the quality of the sync depends on the time source. It must not drift respective to the music's sync.

For more sophisticated purposes, for example if you want to have multiple effects running at the same time, or run transition effects for a period, either you stick with the manual if ... else sequence like such:

if (ms >= 0. && ms < transition1StartMs) {
effect1 (ms);
} else if (ms >= transition1StartMs && ms < transition1EndMs) {
transition1 (effect1(ms), effect2(ms));
} else if (ms >= transition1EndMs && ms < transition2Ms) {
effect2 (ms)
}

Or you design a timeline system: tracks of effects with ending and starting points. The problems is when you want to compose effects together. Then you need to have a certain order of operation between tracks.

It is also particularly interesting to either be able to restart the effect from the beginning ( effect (ms - clipBeginningMs) or keep it running. ( effect (ms) )

See for example mfx or kewlers demos for a good use of the two methods. Sometimes they will slice an effect with cuts of another effect, sometimes they will play the same effect for a while, but resetting the origin at given sync points. Making it appear to jump.

Historically, we also used the module player as a sync device, for effect control. Since one could add custom commands inside the module, that would be ignored by the sound player, but could be processed and detected by your effect code. This *could* be carried over today by embedding information inside the music stream (.ogg for example)

Another historical but still practical method to create your timeline, is spacebar-synching: run a special development version of your demo that record spacebar presses in time as transitions from one effect to another. You obtain a file with sync points that you can then include in your released demo.

[Post edited by _-_-__ on Saturday 15 July 2006 - 10:25]

posted on 2007-07-31 13:13 sundeepblue 阅读(...) 评论(...) 编辑 收藏

转载于:https://www.cnblogs.com/sundeepblue/archive/2007/07/31/837509.html

sync in demos相关推荐

  1. Go 学习笔记(67)— Go 并发安全字典 sync.Map

    1. 并发不安全的 map Go 语言中的 map 在并发情况下,只读是线程安全的,同时读写是线程不安全的. 换句话说,在同一时间段内,让不同 goroutine 中的代码,对同一个字典进行读写操作是 ...

  2. Go 学习笔记(66)— Go 并发同步原语(sync.Mutex、sync.RWMutex、sync.Once)

    1. 竞态条件 一旦数据被多个线程共享,那么就很可能会产生争用和冲突的情况.这种情况也被称为竞态条件(race condition),这往往会破坏共享数据的一致性. 举个例子,同时有多个线程连续向同一 ...

  3. Error: Gradle project sync failed. Please fix your project and try again.

    下载一个demo  显示是这样的 这样问题的处理方法 1 首先检查下gradle 是否下载了 如果出现下面文字提示是没有下载了,可能是网络的问题引起的问题 Gradle sync failed: Co ...

  4. Go 学习笔记(23)— 并发(02)[竞争,锁资源,原子函数sync/atomic、互斥锁sync.Mutex]

    本文参考 <Go 语言实战> 1. 竞争状态简述 如果两个或者多个 goroutine 在没有互相同步的情况下,访问某个共享的资源,并试图同时读和写这个资源,就处于相互竞争的状态,这种情况 ...

  5. linux系统安装deamonsync,DAEMON Sync的使用心得体会。简易版家庭云服务器!正是我要的那种...

    作为一个超级菜鸟,今天学会了自己建立一个简易的局域网云盘,以后就可以让家里人同步照片进电脑了!我的需求仅仅如此而已! (1)保证所有设备在同一局域网内.(我现在的理解就是在同一个路由器内,不知道是不是 ...

  6. android jar 电子书下载,【Android】Gradle project sync jar包长时间下载不下来的解决办法...

    当我们新建一个Android项目,或者在项目中依赖使用一个新的第三方库时,Android Studio经常会从jcenter或者maven仓库下载jar包,但是我们的网络环境不一定一直那么的顺畅,当网 ...

  7. 对于sync.Mutex使用注意事项

    1.sync.Mutex的初始化注意事项 type MemProvider struct { lock     *sync.Mutex              //用来锁 sessions map[ ...

  8. golang的临时对象池sync.Pool

    今天在写码之时,发现了同事用到了sync.pool.因不知其因,遂Google之.虽然大概知道其原因和用法.还不能融汇贯通.故写此记,方便日后查阅.直至明了. 正文 在高并发或者大量的数据请求的场景中 ...

  9. Go中协程间通信的方式Sync.Cond

    在Go中协程间通信的方式有多种,最常用的是channel.如果牵扯多个协程的通知,可以使用sync.Cond. 1. 程序中的通信方式 GO语言中有句名言:"不要用共享内存来通信,而是使用通 ...

  10. linux刷新磁盘的命令,sync命令 – 刷新文件系统缓冲区

    sync命令用于强制被改变的内容立刻写入磁盘,更新信息速度非常快, 在Linux/Unix系统中,在文件或数据处理过程中一般先放到内存缓冲区中,等到适当的时候再写入磁盘,以提高系统的运行效率. syn ...

最新文章

  1. 生物信息学就是从统计和CS的community里借鉴合适的方法
  2. 使用定制的NSDictionary的方法,对NSArray进行排序(附:数组排序两种常见方法)
  3. [导入]我翻译的JavaScript文章
  4. tf.assign()函数简单解释
  5. mysql内存不断被占用,导致每隔一个多月就自动重启,修改数据库配置后,问题解决...
  6. c++读取json文件_[SpringMVC]-SpringMVC架构-07-SpringMVC文件上传
  7. 面试干货 | Java 能否自定义一个类叫 java.lang.System?
  8. SQL Server占用服务器内存过高
  9. 补习系列(4)-springboot 参数校验详解
  10. STC学习:可切换内容的电子音乐
  11. FineReport帆软学习笔记汇总
  12. 微信小游戏开发之使用云开发作为后台服务
  13. 分布式事务的四种解决方案
  14. PHP方法,传入的参数前带三个点是什么意思?
  15. 安装AAE v11.x Control Room简易教程
  16. 红孩儿编辑器的模块设计10
  17. 如何培养自己积极的心态-思维与习惯影响未来,积极的心态决定了成功的85%
  18. 2022-6-5 供暖器,最小差,两地调度,峰与谷
  19. 熬夜加班赚钱?放弃吧,你的基因里有一个大写的穷。
  20. 刚刚大学毕业,自己搭网站遇到的问题 一:tomcat中同时部署两个项目的问题

热门文章

  1. python实现列表去重改变顺序_python实现文本去重且不打乱原本顺序
  2. PPT中均匀分布各图形(水平或垂直)
  3. SQL Sever — 设置外键+组合键(唯一性约束)、修改取值范围、设置某列的默认值
  4. Android RelativeLayout 相对布局
  5. 实现对接顺丰业务的订单管理系统
  6. ROS 日志消息(C++)
  7. 第九章:Servlet工作原理解析
  8. JAVA中获取工程路径的方法
  9. Android 系统javadoc符 注释/**@hide*/
  10. WCF基础学习笔记--创建WCF服务